I'm developing an application in vb.net that use Microsoft.Office.Interop.Word for printing an output in a Word document. If I close the application I want to close the doc (with the "Save As..." dialog). If the user wants to close the doc before the application ends this should be possible. Everything seems work fine, but after the closing (in both the case) I get this error:
This file is in use by another application or user.
(C:...\Templates\Normal.dotm)
I supposed the problem is that the doc owner is the application so the user can't close it... But the error also happens when the doc is closed by the application (with the quit method).
The code I run in frmMain_FormClosing is:
If _objWord IsNot Nothing Then
Try
_objWord.Quit()
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(_objDoc)
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(_objWord)
Catch ex As Exception
End Try
End If
I do the same with Excel and I don't have any problem.