VBA open document
Posted on 2004-11-14
I'm not sure if this is the right place for this question so if there is a better place to post it, pleast tell me. I have a COM addin for MS Word. Whenever the user presses a button on a toolbar I created in Word, I want to call a method, UpdateDocument, on the COM addin and pass it the full text of the current document. This is what my application does:
1) When a new Word document is created, I get a DocumentChange event and in it, I call the Init method of my addin. This returns an id number.
2) When the user clicks the toolbar button, I call the UpdateDocument method and pass it the id number of the ActiveDocument as well as the full text of the Active Document (I've been using ActiveDocument.Range.Text. Is this right?).
My question: Is there any way for me to associate an open document with an id number? I could do it with a global hashtable where ids were indexed by filenames of documents, but VBA doesn't have a hashtable structure. Maybe it's possible to set variables or store data in documents themselves and access these variables/data via ActiveDocuement? Is there any way to do this?
P.S. I am running VBA code from a template if that's important. Thank you very much for your help. If you need my VBA code, just ask.