![how to activate equation tool in word document how to activate equation tool in word document](http://www.tstat.it/old_files/software/MathType/Images/word_mt_tab_popup.gif)
'release' the filename and you get a ' file busy' message, or message about 'creating If you want to re-open the document after closing it It works, but there should be a better solution.īeware that there are a variety of problems that can be encountered:
#HOW TO ACTIVATE EQUATION TOOL IN WORD DOCUMENT CODE#
The code I've found to work around this amounts to simulating the process of selecting END PROCESS in task manager. If you're not careful you'll end up with multiple WINWORD processes,viewable in task manager, regardless of whether you Close or Quit them in your code. I run into this a lot with excel VBA, and Word VBA seems to function identically in that regard.Īlso, VBA is flaky about releasing application objects. IF there's any doubt you're better off referring to a document through the Documents collection, though this can also cause errors if the document is no longer open, and you might have to resort to iterating through the collection to be sure the document is, in fact, open. It is important to be careful with ActiveDocument, because it's not always self-evident what actions, in code or elsewhere, will make a document 'active' (i have no proof but even an autosave might do it). By opening the document with your code you make it the active document, which you then close in the next line and try to activate in the next, and this fails because the document is no longer open.
![how to activate equation tool in word document how to activate equation tool in word document](https://i.stack.imgur.com/D2Urv.png)
I haven't really been able to find much documentation about this, so thanks in advance for any suggestions and insight! Activate on the already active document cause an error? Open on a document explicitly set the Document to be the ActiveDocument? Also, does calling. Activate, it appears that ActiveDocument is set to the origDoc document, even if there were other documents already opened (I'm not really sure how the Documents Collection is managed, and how Word determines what next ActiveDocument would be if you programatically close the current ActiveDocument) My thought was that I needed to call Activate to ensure that the original document was the ActiveDocument, but I'm getting a 4160 'Bad file name' error on the. The user opens a document in Word 2003, and within the Normal.dot AutoOpen macro, we look at current document, and if it has been opened by clicking on a link on a webpage, and meets certain other application specific criteria, close the streamed 'copy' and open the source document (found on a shared drive we can assume the user has access to): Documents.Open origDocĭocuments(ActiveDocument.FullName).Close SaveChanges:=wdDoNotSaveChanges I'm hoping a VB/VBA expert can help me out.