Opening an MS Word doc from Excel file.
Posted by Michele on May 31, 2001 11:49 PM
To open an MS Word file from and Excel Workbook, I use the following VB code (thanks to guidance from Ivan Moala). This works but the problem is that it opens a new copy of MS Word everytime it gets executed and it also opens the file requested even if that file is already opened.
Static WordObj
Set WordObj = Nothing
Set WordObj = CreateObject("Word.Application")
On Error GoTo FileErr
WordObj.Documents.Open (FileNm)
On Error GoTo GenErr
WordObj.Visible = True
So to solve my problem, does anyone know how to do the following:
If desired MS Word file is already opened, then
Activate MS Word & file.
Goto EOJ
ElseIf MS Word is already opened, then
Open desired MS Word file but not a new MS Word.
Goto EOJ
Else Goto execute my above code which opens MS Word
and the desired MS Word file.
Goto EOJ
End If
Many thanks,
Michele