May I assign the objDoc
as a document of the ObjWord
(after Set objDoc = oDoc.Object
)?
My code looks like this:
'Declaration
Dim oDoc As OLEObject
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim WS as Worksheet
Dim strOdoc as String
'Initialization
Set WS = Whorksheets("Sheet1")
strOdoc = "WordDoc"
Set objWord = New Word.Application
'Set objWord = GetObject(, "Word.Application")
'I need using GetObject to be able to made the activated OLEDocument, invisible.
'And Need Set objWord = New Word.Application to be able
'to EndTask the WINWORD.EXE with objWord.Quit.
objWord.Visible = False
Set oDoc = WS.OLEObjects(strOdoc)
oDoc.Activate
Set objDoc = oDoc.Object
'I need here Add the objDoc to the objWord
- I need
objDoc
to have been a document of theobjWord
object, which has been hidden withobjWord.Visible = False
(I can't useDim objDoc As objWord.Document
variable declaration). - I need the
objWord
to have been isolated because when usingobjWord.Quit
, it must not try to close other Word Documents. (Here I usedSet objWord = New Word.Application
) - I need using the
GetObject
statement to be able to made the activated OLEDocument invisible. - And Need Set
objWord = New Word.Application
to be able to EndTask the WINWORD.EXE withobjWord.Quit
. But how can integrate two above advantages: 1) Working Invisible with the OLEObjectDocument and 2) Perform EndTask the WINWORD.EXE if no other word documents are opened?