Wrapper class for Word documents?

Add-in Express™ Support Service
That's what is more important than anything else

Wrapper class for Word documents?
 
Chris Ward




Posts: 1
Joined: 2008-12-12
Hi,

I'm not a professional developer, so please bear with me. I'm trying to create wrapper classes for word documents in VB.Net Express. For a long time, I couldn't figure out even how to access the AddinModule WordApp property (ie, the Word Application instance) from my document wrapper class. I needed to do that so that I could create an instance of a Word document inside my wrapper class. I finally did it by using a delegate. My Sub New() takes a delegate as a parameter from the Addin Module and then uses the delegate to call back to a function in the Addin Module that returns the WordApp property/Application instance. Then my Sub New() uses the Word Application Instance to create a new document from a template and add it to the documents collection. So far, so good. When I run the application, it opens a new document just fine.

My problem comes when I try to access any of the document's properties and methods through the Word object model. My wrapper class has a read only public property called DocumentInstance, which is set to the private document member variable. Any call to DocumentInstance, for example, MsgBox(DocumentInstance.Paragraphs.Count), causes Word to crash.

Anybody know what I'm doing wrong?

Any help would be greatly appreciated. :D
Posted 12 Dec, 2008 14:03:18 Top
Eugene Astafiev


Guest


Hi Chris,

Do you release COM objects properly? Please read the following http://www.add-in-express.com/creating-addins-blog/2008/10/30/releasing-office-objects-net/.
Posted 12 Dec, 2008 14:38:39 Top