|
-
June 9th, 2000, 10:07 AM
#1
I need Simple Clarification on opening a Word document
I want to do a simple task of opening up a Word document (ex. c:\testprint.doc), go to a bookmark (ex. testmark) , insert some text ("John Smith"), print the document and close the document without saving the document
I would also like to get fancy and check if Word is already up and running and just open the testprint.doc in it so I don't have multiple copies of Word running, which would speed things up not having to fire it up each time.
I am a rookie and have tried to learn on my own, but now I am just confused and don't know the correct way of doing it. I would like to find out what is the best way and stick with it to be consistent.
I have looked at different places for examples, put they all seem different
I have listed some example below:
An example that has the word "New" in front of "Word.Application" and doesn't use a "set" statement and opens the file with an "Open Filename=" statement
Dim Docname As String
Dim Wrd As New Word.Application
Docname = "c:\testprint.doc"
Wrd.Documents.Open Filename=Docname
Another example that has a "Dim" and a "Set" statement and makes the objWord visible (does it need to be visible?)
Dim objWord as Word.Application
on error GoTo ErrSection
set objWord = new Word.Application
objWord.Visible = true
ErrSection:
MsgBox Err.Description
MsgBox Str(Err.Number)
Another example that uses "Object" and "CreateObject" and "Quit" and "set to nothing" (what does this do?)
Dim xlApp as Object
set xlApp = CreateObject("word.application")
xlApp.Visible = true
' do something
xlApp.Quit
set xlApp = nothing
Another example that opens the file with "Open("???.doc")" statement
Dim oWordObj as Object
Dim oWordDoc as Object
'
set oWordObj = CreateObject("Word.Application")
set oWordDoc = oWordObj.Documents.Open("c:\test.doc")
Any help on either an quick example or at least clarification on why some people are doing things differently would be GREATLY appreciated,
Thanks,
Trevor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|