loWord = CREATEOBJECT("Word.application") loDoc = loWord.Documents.Open("c:\Files\Home.docx") loRange = loDoc.Content loRange.Find.ClearFormatting() loRange.Find.Replacement.ClearFormatting() loRange.Find.Execute("^g",.F.,.F.,.F.,.F.,.F.,.T.,1,.F.,"",2,.F.,.F.,.F.,.F.)As to the result, the range object will be changed:
loRange = loDoc.Content loRange.Find.ClearFormatting() loRange.Find.Replacement.ClearFormatting() loRange.Find.Font.Bold = .T. loRange.Find.Execute("",.F.,.F.,.F.,.F.,.F.,.T.,1,.T.,"",.F.,.F.,.F.,.F.,.F.) ?loRange.Text ?loRange.Start ?loRange.End>Hello, I use Microsoft Office Automation by Granor and Martin, and have had great luck over the years. But I recently ran into a problem with the FoxPro automation of Word, using find.
>oWord.Selection.WholeStory >oWord.Selection.Fields.Unlink >oWord.Selection.HomeKey(wdStory) && remove all hypinks >>
>** go to top of doc first >oWord.Selection.Find.ClearFormatting && next find >oWord.Selection.Find.Replacement.ClearFormatting >With oWord.Selection.Find && remove those pictures > .Text = "^g" > .Replacement.Text = " " >EndWith >IF oWord.Selection.Find.Found >oWord.Selection.Find.Execute(wdReplaceAll) >endif >*WAIT WINDOW "pictures" >>
>oWord.Selection.HomeKey(wdStory) && go home >oWord.Selection.Find.ClearFormatting && ready for find and delete >oWord.Selection.Find.Replacement.ClearFormatting >With oWord.Selection.Find > *.Text = "Print | Close Window" > .Text = "Print" > .Replacement.Text = " " > .replacement.paragraphFormat.leftIndent = 12 > lFound = .execute( , , , , , , , , , , wdReplaceAll) >*********************1 5 10************* >EndWith >oWord.Selection.Find.Execute(wdReplaceAll) >>
>oWord.Selection.HomeKey(wdStory) && go home >oWord.Selection.Find.ClearFormatting >oWord.Selection.Find.Font.Bold = .F. >oWord.Selection.Find.Replacement.ClearFormatting >With oWord.Selection.Find > .Text = "" > .Replacement.Text = " " > .Forward = .F. > .Format = .F. > .MatchCase = .F. > .MatchWholeWord = .F. > .MatchWildcards = .F. > .MatchSoundsLike = .F. > .MatchAllWordForms = .F. >EndWith >oWord.Selection.Find.Execute >oWord.Selection.Copy > ** file 22 >*WAIT WINDOW "first bold title" >>
>titleRange = ALLTRIM(oWord.ActiveDocument.Range(0,50).Text) >>