Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selecting Text in Word
Message
From
10/05/2001 10:18:16
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00505735
Message ID:
00505763
Views:
21
>I am using the Find method to locate a specific string of text in a Word doc. The Execute() is returning TRUE, so now I want an object reference to that. I am trying oRange = oWord.Selection which does return an object reference.
>
>However, when I try to perform operations on that selection, I find that the selection [cursor position in the Word Doc] is somewhere else [e.g., the beginning of the document]. If I actually do this Find in the Word doc manually, the string is found and selected. When I do this via automation, the string is found but not selected.
>
>The code looks like:
>with loRange.Find
>   .ClearFormatting()
>   .Text = This.cFindValue
>   .Replacement.Text = ""
>   .Forward = .t.
>   .Wrap = wdFindContinue
>   .Format = .f.
>   .MatchCase = .f.
>   .MatchWholeWord = .f.
>   .MatchWildcards = .f.
>   .MatchSoundsLike = .f.
>   .MatchAllWordForms = .f.
>   llRetVal = .Execute()    && RETURNS TRUE
>endwith
>if llRetVal
>   return This.oWord.Selection  && return an object reference
>else
>   return .null.
>endif
>What am I missing? TIA!

Mark,
Select the range and execute find with selection :
loRange.Select
llRetVal = This.oWord.Selection.Find.Execute(lcFindValue)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform