View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob van Gelder[_4_] Rob van Gelder[_4_] is offline
external usenet poster
 
Posts: 1,236
Default opening a word document from excel: file still won't load

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" wrote in message
...
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.