Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word 2013 Find does not work

Status
Not open for further replies.

amulder

Programmer
Aug 16, 2010
4
NL
Hi,

We use VFP70 and in our application have Word automation.
Since Word 2013 the Find function does not work annymore, while all prior versions worked correctly.
We get an OLE error 1429 "this method or proerty is not available..."
Anybody knows what is going on?

code snippet:

with loSelection.Find
.clearformatting
.forward = .t.
.wrap= 1
endwith
llFound = loSelection.Find.execute(tcFind)

Thanks in advance for any help or suggestions.
André
 
ClearFormatting is a method. Try putting parens after it.

Code:
.ClearFormatting()

Tamar
 
I already tried .ClearFormatting and .ClearFormatting()

To be more specific, the error rises at the .execute command.
I tried also different kind of calling methods like:

Code:
with loSelection.Find
  .text = "findme"
  .forward = .t.
  .wrap = 1
  .execute()
  llFound = .found
endwith

but without any succes.
It al gives an error at te .execute command.

The strange thing is, using Word2003, Word2007, Word2010, the code does what has to do.
Another strange behaviour, is theFind and Replace function, is almost the same, but thatdoes work properly, in all Word versions.
 
Have you tried running the code directly in Word, as a macro? That would tell you whether it is the Word code or the VFP code that is at fault.

Also, try running it in both versions of Word. That might give you a clue as to any differences between the versions.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks for all replies.

Yes, I tried doevents: no result
Yes, I googled: no specific solution found, only examples which we use in our code

I just tried my code as a macro in Word2013: it works properly.

So...how strange is it, that it will suddenly not work from our VFP70 application with Word2013?

 
You don't show how you define loSelection. As far as I now could test, Find is no member of a selection, but of a range, eg loSelection.Range.Find may exist.

Code:
loWord = CreateObject("Word.Application")
loWord.Visible = .T.

loDocument = loWord.Documents.Add()
loDocument.Range.Insertafter("This is a test, can you findme?")
loDocument.Sentences(1).Select()
loSelection = loWord.Selection

with loSelection.[COLOR=#CC0000]Range[/color].Find
  .text = "findme"
  .forward = .t.
  .wrap = 1
  .execute()
  llFound = .found
endwith 
? llFound
This works for me, for example, in VFP9 with Word 15.0 aka Word 2013.

But if loSelection really is a Selection and not a Range, it doesn't have a Find member object.

Bye, Olaf.
 
Thank you Olaf for your suggestion.

loSelection is more or less your code:
Code:
lcFile = "reference_to_file"
loWord = CreateObject("Word.Application")
loWord.Documents.open(lcFile)
loSelection = loWord.Selection

I tried the addition "Range" but without succes.
Maybe it is the combination with VFP70 ... because you are using VFP90.

But...I have found a solution, it's more a work-around.
(So I still don't know why Word 2013 does not accept the Selection object)
Code:
loSelection = loWord.ActiveDocument.Content

The difference with the "Selection" object, is that the Find function wil not select the result.
In my case this is not necessary.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top