Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error while using Word Object Model

Status
Not open for further replies.

AdamDW

Programmer
Aug 25, 2011
3
US
I am trying to complete the creation of a report using the Word Object Model in Visual Basic 2008. After the report is created ans saved as a .doc file, I want to close the document, but everytime that it gets to my close command, I end up receiving an error stating . . .

"Microsoft Office Word has encountered a problem and needs to close. We are sorry for the inconvenience."

I have tried each of the following commands to no avail:

* Me.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
* Application.Documents(reportname).Close(Word.WdSaveOptions.wdDoNotSaveChanges)
* Me.Application.ActiveDocument.Close(Word.WdSaveOptions.wdDoNotSaveChanges)

I have previosuly updated my Office 2007 package with Service Pack 1. Is there anything that can be done?

Please advise.

Thanks.
 

You should release the COM object when done:

System.Runtime.InteropServices.Marshal.ReleaseComObject(<name of Word object here>)

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top