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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To find a certain line in a Word-Document

Status
Not open for further replies.

german12

Programmer
Nov 12, 2001
563
DE
I have combined a word-document called telefon.doc as a help-file with a foxpro-application
by calling it with this command via a command-button:

oWord = CREATEOBJECT("WORD.APPLICATION")
oWord.Documents.Open("C:\daten\telefon\telefon.doc")
oword.visible = .t.

That works fine - WORD opens the file correctly for the user.

However it would be fine, if I could open that doc in a matter that the cursor
in Word will be let us say on line #20 so that the user could read immediately what is
said to his work.

Is that possible by an additional parameter which opens Word on a requested line?

Regards from Germany

Klaus

 
There may be a command to open Word at a certain line, but I have not yet come across it. However there are a few ways to get to the line that you require using the find.execute command :

Create bookmarks in your word file, then jump to the correct bookmark (advised)

Search for specific text where you wish to jump to (could get to the wrong place)

Go to a specific line number (will be wrong if the text changes)

It is a bit rough trying to get the correct parameters and objects, but it is well worth it in the end
 
Sorry, don't use the find.execute command for bookmarks. Here's a bit of a leg-up for you:

oWord.activedocument.bookmarks("yourbookmarkname").select

Will jump to the bookmark called "yourbookmarkname"

Word from foxpro is a bit of a hobby of mine ...
 
Hi Derren,

Congratulations! That was a very good hint for me.

It is now very flexible to provide the user with a help-file via foxpro.
When he clicks the right-mouse button while he clicks on a command-button or form etc.
the following code works immediately


searchword = "Saleslist"
oWord = CREATEOBJECT("WORD.APPLICATION")
oWord.Documents.Open("C:\FORCANEU\FORECAST.doc")
oword.visible = .t.
oWord.activedocument.bookmarks(searchword).select

...and immediately the word screen shows the right place matching the to the work request.

It is easy to copy the code - because you only have to change the searchword (the first line)
within in the above code and can put this code behind every button you want.

And also the bookmark will remain correct when other text ist added to the information
below the bookmark.

I think this is much more easy to understand than a graphical help-file with a foxpro-table
behind.
And also you can organize the word-document very simple....

Thank you again - come to Germany and have a beer with me!

Regards
Klaus
 
Cheers!

It does seem like a very nice solution for users with Word installed and a worthy addition to my Word tips collection!

Derren

[The only person in the World to like MS Word]
 
DeltaWind

Next time you have a question, you may consider starting a new thread.
But if you question is "How to open a Word Document read-only in FoxPro", try this:
Code:
loWord=CREATEOBJECT("word.application")
loWord.Documents.Open("c:\doc1.doc",.t.,.t.) && Third parameter is the read-only setting.
loWord.Visible=.t.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top