I can open multiple instances of Word from VB, but I can't figure out how to open one instance of Word and have multiple documents open.
How can that be done?
Printable View
I can open multiple instances of Word from VB, but I can't figure out how to open one instance of Word and have multiple documents open.
How can that be done?
Try using GetObject instead of CreateObject.
Good luck!Code:Private wrd As Word.Application
Private Sub OpenDoc(sFileName As String)
On Error Resume Next
Set wrd = GetObject(, "Word.Application")
If Err Then
'an error has been raised, assuming Word is not started
Set wrd = CreateObject("Word.Application")
End If
'the rest of the code
End Sub