K
kai.iske
Hi,
I have two documents. One that contains an AutoOpen implementation much
like this:
Sub AutoOpen()
...
' Do some magic here which is of no relevance to the problem
...
ThisDocument.Close wdDoNotSaveChanges
End Sub
The other document / add-in contains a method that loads in the first
document and then attempts to continue to do its processing. Here's a
sample "implementation" of that method
Sub Test()
Application.Documents.Open ("AutoCloseTest.doc")
MsgBox "Hello"
End Sub
(Assumption is that the document containing the call to
ThisDocument.Close() in its AutoOpen metho is called AutoCloseTest.doc
and located in the same directory)
I stripped it down to hopefully make it clear. When I debug the Test
method in VBA and execute the Open(...) line I do see that the AutoOpen
enabled document gets opened and will close itself after processing.
However the VBA debugger does not continue to execute the MsgBox
"Hello" line.
Anyone out there who knows the reason for this behavior? My real code
is a bit more complex and involves a global Add-In that in turn
registers a menu and initializes a C++ based COM Server CoClass. When
this Add-In attempts to open the "AutoCloseTest.doc", I see my COM
Server CoClass being released as if the Add-In gets reinitialized. I
guess this all has something to do with the strange behavior outlines
above.
Any help would be highly appreciated.
Thanks in advance
Kai Iske
I have two documents. One that contains an AutoOpen implementation much
like this:
Sub AutoOpen()
...
' Do some magic here which is of no relevance to the problem
...
ThisDocument.Close wdDoNotSaveChanges
End Sub
The other document / add-in contains a method that loads in the first
document and then attempts to continue to do its processing. Here's a
sample "implementation" of that method
Sub Test()
Application.Documents.Open ("AutoCloseTest.doc")
MsgBox "Hello"
End Sub
(Assumption is that the document containing the call to
ThisDocument.Close() in its AutoOpen metho is called AutoCloseTest.doc
and located in the same directory)
I stripped it down to hopefully make it clear. When I debug the Test
method in VBA and execute the Open(...) line I do see that the AutoOpen
enabled document gets opened and will close itself after processing.
However the VBA debugger does not continue to execute the MsgBox
"Hello" line.
Anyone out there who knows the reason for this behavior? My real code
is a bit more complex and involves a global Add-In that in turn
registers a menu and initializes a C++ based COM Server CoClass. When
this Add-In attempts to open the "AutoCloseTest.doc", I see my COM
Server CoClass being released as if the Add-In gets reinitialized. I
guess this all has something to do with the strange behavior outlines
above.
Any help would be highly appreciated.
Thanks in advance
Kai Iske