View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Problems starting Word from Excel VBA

GetObject("Word.Application") hijacks a running instance of the
application, and so if Word is not running then your reference *Is
Nothing*!

CreateObject("Word.Application") starts an automated instance of Word
if it's installed on the machine. If not installed then your reference
*Is Nothing*!

I don't see where you check to see that the instance of Word you want
to use actually exists...


Dim oWD As Object

Set oWD = GetObject("Word.Application")
If oWD Is Nothing Then CreateObject("Word.Application")

If Not oWD Is Nothing Then
'if you got here then
'you have a fully qualified ref
'to a running instance of Word,
'so do stuff!
End If

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion