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

Word Automation - End of Document 2

Status
Not open for further replies.

FoxEgg

Programmer
Mar 24, 2002
749
AU
When loading a Word document with automation ... I have used GETFILE() to select a document....

After selecting a document to open ...

Is there a simple command/instruction I can use which takes me to the end of the document... (ie so the typists can add an entry to the end of an existing file)

Thanks in advance...

John Fox
 
John,
In fox you can issue:

KEYBOARD '{CTRL+END}'

to take you to the bottom of a doc. Whether that will work once you're inside the word doc or not, I'm not certain. Since you have to take the focus off the Fox application to select the word document, it might not work. (Haven't tried it). The other alternative might be to establish a word macro that is fired automatically when you start word, while passing it the file name. Like:

RUN WORD.EXE MYDOC.DOC

I'm not certain, but I think you can set word up to execute a macro on starting it. It would likely be the same kind of thing, since a windows standard of CTRL+END keys will always take you to then end of any document. I'm not well versed at all in VBA (Visual Basic for Applications) which is the scripting language for Word, so maybe someone else can help you with that.

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
FoxEgg

Not pretty, but it works:
Code:
LOCAL lcFile
oWord=CREATEOBJECT("word.application")
lcFile = GETFILE("doc")
oWord.Documents.open(lcFile)
oSelection=oWord.Selection
oSelection.WholeStory && =Select all
oSelection.Paste && Paste over the existing open document which brings the cursor to the end of the document
oWord.visible =.t.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Hej !
As TheManiac suggested I propose to use macro in VBA of Word. At the Event OPEN:

Private Sub Document_Open()
Selection.EndKey Unit:=wdStory
End Sub

But if I remember OPEN() is don't work in OLE and you must execute it.
Kind regards from Warsaw !!!!!
Monika (monikai@yahoo.com)
 
TheManiac

Whether that will work once you're inside the word doc or not, I'm not certain. Since you have to take the focus off the Fox application to select the word document, it might not work. (Haven't tried it).

I tried your suggestion (KEYBOARD '{CTRL-END}') and I cannot make it work. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
This should work:

#DEFINE wdStory 6
oWordApp.Selection.EndKey(wdStory)
 
wgcs

#DEFINE wdStory 6
oWordApp.Selection.EndKey(wdStory)


That's it!!
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Awesome......

Thanks to everyone.

As far as the suggestions on RUN

I found this reference on an earlier question in 2000 (I searched for WORD AUTOMATION in keywords) David Grewe suggested:


Which is a neat description of how to use shellexecute() and how it replaces the RUN command.

Recommended reading.

Thanks again.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top