opening a word document from excel: file still won't load

G

Guest

this is what i used
dim Wrd as Word.Application, MyDoc as Word.Documen

Set Wrd = CreateObject("Word.Application"
Wrd.Visible = Tru
Set Wrd = GetObject(, "Word.Application"
Set MyDoc = GetObject(MyFilePath

still i get no file loaded in word, as a matter of fact code execution suspends after it runs the last line.
 
R

Rob van Gelder

Const MyFilePath = "C:\T\Doc1.doc"

Sub test()
Dim wrd As Word.Application, doc As Word.Document

On Error Resume Next
Set wrd = GetObject(, "Word.Application")
If Err.Number Then Set wrd = CreateObject("Word.Application")
On Error GoTo 0
wrd.Visible = True
Set doc = wrd.Documents.Open(MyFilePath)
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


chris said:
this is what i used:
dim Wrd as Word.Application, MyDoc as Word.Document

Set Wrd = CreateObject("Word.Application")
Wrd.Visible = True
Set Wrd = GetObject(, "Word.Application")
Set MyDoc = GetObject(MyFilePath)

still i get no file loaded in word, as a matter of fact code execution
suspends after it runs the last line.
 
B

Bob Phillips

Chris,

You have to force it out into the open <vbg>

myDoc.Application.Visible = True

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

chris said:
this is what i used:
dim Wrd as Word.Application, MyDoc as Word.Document

Set Wrd = CreateObject("Word.Application")
Wrd.Visible = True
Set Wrd = GetObject(, "Word.Application")
Set MyDoc = GetObject(MyFilePath)

still i get no file loaded in word, as a matter of fact code execution
suspends after it runs the last line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top