C
che
Hi there,
I am using Word 2003 and visual studio 2008 to create a document manager via
automation.
I have been able to trap the DocumentBeforeClose event. I am doing this to
save the active document as a blob file to the database before the document
is closed. The DocumentBeforeClose event is hit successfully, but when right
before my SaveBlob procedure, my entire application hangs for a couple of
seconds and I get a "Microsoft Office Word has encountered a problem and
needs to close. We are sorry for the inconvenience." error. On clicking
"Don't Send", the document I had been working on re-opens in a new instance
of Word in a completely seperate window to my application. The inner
exception information is not useful at all.
Here is a code sample of what i'm trying to do:
wdEvents = DirectCast(wd, Word.ApplicationEvents4_Event)
AddHandler wdEvents.DocumentBeforeClose, AddressOf SaveBlob
'I am clicking on the x at the document level in word to catch this event.
Private Sub SaveBlob ()
If Not (CurrentDoc) Is Nothing Then
MsgBox("Closing the Window. Your current doc will be saved. ")
'Error occurs here, before save doc is called.
SaveDoc()
CloseCurrentDoc()
End If
End Sub
Any help/suggestions would be muchly appreciated.
Thanks
I am using Word 2003 and visual studio 2008 to create a document manager via
automation.
I have been able to trap the DocumentBeforeClose event. I am doing this to
save the active document as a blob file to the database before the document
is closed. The DocumentBeforeClose event is hit successfully, but when right
before my SaveBlob procedure, my entire application hangs for a couple of
seconds and I get a "Microsoft Office Word has encountered a problem and
needs to close. We are sorry for the inconvenience." error. On clicking
"Don't Send", the document I had been working on re-opens in a new instance
of Word in a completely seperate window to my application. The inner
exception information is not useful at all.
Here is a code sample of what i'm trying to do:
wdEvents = DirectCast(wd, Word.ApplicationEvents4_Event)
AddHandler wdEvents.DocumentBeforeClose, AddressOf SaveBlob
'I am clicking on the x at the document level in word to catch this event.
Private Sub SaveBlob ()
If Not (CurrentDoc) Is Nothing Then
MsgBox("Closing the Window. Your current doc will be saved. ")
'Error occurs here, before save doc is called.
SaveDoc()
CloseCurrentDoc()
End If
End Sub
Any help/suggestions would be muchly appreciated.
Thanks