|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Word find.selection on formatted text?I need to find a text string in a Word document which has been put inside a textbox. When I do a normal search in Word it will access the textbox and find the text but when I run my code it will not find the text: wdApp.Selection.Find.ClearFormatting With wdApp.Selection.Find .Text = rstNaam("zoekstring") .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With What do I have to do to find the text? Marco Try this:
http://www.word.mvps.org/faqs/customization/ReplaceAnywhere.htm -- Show quoteHide quoteChris Hanscom - Microsoft MVP (VB) Veign's Resource Center http://www.veign.com/vrc_main.asp Veign's Blog http://www.veign.com/blog -- <vonclausow***@gmail.com> wrote in message news:1138817978.384223.69390@z14g2000cwz.googlegroups.com... > Hi All, > > I need to find a text string in a Word document which has been put > inside a textbox. > When I do a normal search in Word it will access the textbox and find > the text but when > I run my code it will not find the text: > > wdApp.Selection.Find.ClearFormatting > With wdApp.Selection.Find > .Text = rstNaam("zoekstring") > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchWildcards = False > .MatchSoundsLike = False > .MatchAllWordForms = False > End With > > What do I have to do to find the text? > > Marco > Veign,
Saw the code, looks good, tried it but couldn't get it to work, need a little hand. Do While rstNaam.EOF = False For Each myStoryRange In ActiveDocument.StoryRanges With myStoryRange.Find .Text = rstNaam("zoekstring") .Replacement.Text = "" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Do While Not (myStoryRange.NextStoryRange Is Nothing) Set myStoryRange = myStoryRange.NextStoryRange With myStoryRange.Find .Text = rstNaam("zoekstring") .Replacement.Text = "" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Loop Next myStoryRange ||||||||||||||||||||||||||||||||||| next part won't work If myStoryRange.Find.Execute = True Then||||||||||||||||||||||||||||||||||||||||||||||||||| sTempNaam = rstNaam("bestandsnaam") Exit Do End If ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| rstNaam.MoveNextLoop How should I go about? I want to search the doc for the rstNaam("zoekstring"), and when it is found this will become the name of the document: With wdApp With .Dialogs(wdDialogFileSaveAs) .Name = gDiskLetter & sTempNaam & Format(Date, "YYYYMMDD") .Show End With End With like this. Marco I don't have alot of in-depth knowledge of the Word API - Your best bet is
to ask in the Word Programming newsgroup. The MVP's in that group are the ones that wrote the article and would probably help you alot faster than someone here.. Good Luck! -- Show quoteHide quoteChris Hanscom - Microsoft MVP (VB) Veign's Resource Center http://www.veign.com/vrc_main.asp Veign's Blog http://www.veign.com/blog -- <vonclausow***@gmail.com> wrote in message news:1138819772.112279.130370@g47g2000cwa.googlegroups.com... > Veign, > > Saw the code, looks good, tried it but couldn't get it to work, need a > little hand. > > Do While rstNaam.EOF = False > > For Each myStoryRange In ActiveDocument.StoryRanges > With myStoryRange.Find > .Text = rstNaam("zoekstring") > .Replacement.Text = "" > .Wrap = wdFindContinue > .Execute Replace:=wdReplaceAll > End With > Do While Not (myStoryRange.NextStoryRange Is Nothing) > Set myStoryRange = myStoryRange.NextStoryRange > With myStoryRange.Find > .Text = rstNaam("zoekstring") > .Replacement.Text = "" > .Wrap = wdFindContinue > .Execute Replace:=wdReplaceAll > End With > Loop > Next myStoryRange > > ||||||||||||||||||||||||||||||||||| next part won't work > ||||||||||||||||||||||||||||||||||||||||||||||||||| > > If myStoryRange.Find.Execute = True Then > sTempNaam = rstNaam("bestandsnaam") > Exit Do > End If > ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| > > rstNaam.MoveNext > Loop > > > How should I go about? > I want to search the doc for the rstNaam("zoekstring"), and when it is > found > this will become the name of the document: > > With wdApp > With .Dialogs(wdDialogFileSaveAs) > .Name = gDiskLetter & sTempNaam & Format(Date, > "YYYYMMDD") > .Show > End With > End With > > like this. > > Marco > |
|||||||||||||||||||||||