From: Harish Sharma on 5 Feb 2010 08:49 Hi, I have created a find macro to store all the text which are colored into a list box as follows: Sub FindColoredText() Dim CURRENT_DOCUMENT As Range Set CURRENT_DOCUMENT = ActiveDocument.Content With CURRENT_DOCUMENT.Find .ClearFormatting .Font.Color = wdColorRed Do While .Execute(findText:="", Forward:=True, Format:=True) = True UserForm1.WhiteList.AddItem (.Parent) DoEvents Loop End With UserForm1.Show End Sub However, the problem is that this do loop is working on one particular document but in another document it is going into infinite loop. I want to ensure that the find loop starts from begening of the document and exits at the end of the document. I shall be thankful for all your help. thanks,
From: Fumei2 via OfficeKB.com on 5 Feb 2010 14:10 More details required. This puts the .Found of the .Find into a listbox on a userform. What document has the userform? Is, in fact, the document you are searching the document that has the userform? I am not following how another document is involved. What fires Sub FindColored? Something on the userform? Something else? Harish Sharma wrote: >Hi, > >I have created a find macro to store all the text which are colored into a >list box as follows: > >Sub FindColoredText() >Dim CURRENT_DOCUMENT As Range >Set CURRENT_DOCUMENT = ActiveDocument.Content > > With CURRENT_DOCUMENT.Find > .ClearFormatting > .Font.Color = wdColorRed > Do While .Execute(findText:="", Forward:=True, Format:=True) = True > UserForm1.WhiteList.AddItem (.Parent) > DoEvents > Loop > End With > > UserForm1.Show >End Sub > >However, the problem is that this do loop is working on one particular >document but in another document it is going into infinite loop. I want to >ensure that the find loop starts from begening of the document and exits at >the end of the document. > >I shall be thankful for all your help. > >thanks, -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/word-programming/201002/1
From: Fumei2 via OfficeKB.com on 5 Feb 2010 14:13 Just thought of something. You have Userform1.WhiteList.Add BEFORE Userform1. Show. How can you add anything to WhiteList if the suerform is not loaded yet. OR.. .have you loaded it, Done a Hide? Fumei2 wrote: >More details required. This puts the .Found of the .Find into a listbox on a >userform. > >What document has the userform? Is, in fact, the document you are searching >the document that has the userform? I am not following how another document >is involved. > >What fires Sub FindColored? Something on the userform? Something else? > >>Hi, >> >[quoted text clipped - 25 lines] >> >>thanks, -- Message posted via http://www.officekb.com
From: Fumei2 via OfficeKB.com on 5 Feb 2010 14:14 Just thought of something. You have Userform1.WhiteList.Add BEFORE Userform1. Show. How can you add anything to WhiteList if the userform is not loaded yet. OR.. .have you loaded it, Done a Hide? Fumei2 wrote: >More details required. This puts the .Found of the .Find into a listbox on a >userform. > >What document has the userform? Is, in fact, the document you are searching >the document that has the userform? I am not following how another document >is involved. > >What fires Sub FindColored? Something on the userform? Something else? > >>Hi, >> >[quoted text clipped - 25 lines] >> >>thanks, -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/word-programming/201002/1
From: Fumei2 via OfficeKB.com on 5 Feb 2010 14:13
Just thought of something. You have Userform1.WhiteList.Add BEFORE Userform1. Show. How can you add anything to WhiteList if the userform is not loaded yet. OR.. .have you loaded it, Done a Hide? Fumei2 wrote: >More details required. This puts the .Found of the .Find into a listbox on a >userform. > >What document has the userform? Is, in fact, the document you are searching >the document that has the userform? I am not following how another document >is involved. > >What fires Sub FindColored? Something on the userform? Something else? > >>Hi, >> >[quoted text clipped - 25 lines] >> >>thanks, -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/word-programming/201002/1 |