Close/Release Word object in VBA?

I possess the adhering to code to open the guide for an Excel Workbook app I have actually developed:


I have the following code to open the manual for an Excel Workbook application I have developed:

Sub OpenManual()

Dim objWord As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True

objWord.Documents.Open "\\filePath\FormFlow To MSExcel\FeedSampleReport-Manual.docx"

End Sub

This offers me 2 concerns:

If I call off out of that and make an effort to finalize the blank Microsoft Word instance I at that point get:.

So the trouble you are actually possessing with Word asking you to spare the worldwide layout is actually due to the fact that there is presently a copy Word available which possesses civil rights to the Normal theme. When you utilize CreateObject to prepare your Word item you are actually filling up Word a second opportunity which opens up Ordinary theme as checked out just.

The documentation opens, but in the background. The user does not recognize the file has opened up unless they recognize to check out Microsoft Word in the Taskbar.
When I try to finalize words record I get: This documents remains in usage through another application or even user. (C: \ Consumers \ Me \ AppData … \ Normal.dotm).

One other nice series of code is actually to surpress screen informs. This are going to stop the ‘perform you desire to conserve’ kind dialog containers coming from looking.

When I possess one other word document open and also click on the button, the observing happens:.

Edit 1: You developed a.docm file however are you certain you stored your code in the docm documentation and not in the normal.dotm file?

Changes have actually been produced that influence the worldwide theme, Ordinary. Perform you would like to save those modifications?

What you require to accomplish is examine if Word levels or even certainly not as well as if it is actually snatch that copy of Word. If it’s not at that point you may open Word.

If this paper is actually the initial occasion of word I have position:.

When I click on ok about that conversation, I get a “Save As” display screen.

I may not replicate your complication operating the precise same code. This enhance the idea that you composed your code under Normal -> Microsoft Word Objective -> ThisDocument while in the VBA frame.

You perhaps stashed it in normal.dotm file This code will relate to all documents. You ought to quick as well as stash it in component that resides in the paper your are actually taking care of.

I am actually merely preferring the document to open to the center permitting users to view the Manual for aid when they require it, as well as allow all of them shut the document at their discernment.

The record opens up.
As soon as code strikes the objWord.Quit line the documentation instantly finalizes.

Edit 2: I created a word test.docm file as well as put your code in a brand-new module (under job( Exam) -> Elements -> Module 1). After that I began the code and also it develop 1 paragraph every files in the exact same folder (providing they respect the sign in your IF condition). I moved that code in Job( Test) -> Microsoft Word Furniture -> ThisDocument; so it operates at opening. It carries out specifically the very same as intended at the position. I evaluated opening up various other word documentations (docx as well as docm) in the exact same folder and also the code performed certainly not work.

I produced a Word file, created the macro and also spared the documents with ‘. docm’ extension. Next off, I stole that file to many another roads and transformed its label. After that, my macro fires on practically all Word papers after opening all of them, regardless of whether they are actually not copies of the authentic paper.

Hands-on opens up in the forefront, but I instantly get This data is in usage by yet another treatment or even consumer. (C: \ Consumers \ Me \ AppData \ … \ Normal.dotm).
I press ALRIGHT and also get the Save As dialogue.
Negate of the Save As discussion and also am actually presented my Guidebook paper.
When I click on the Red X to finalize the documentation, I obtain Improvements have been actually made that influence the global theme, Regular. Do you intend to spare those adjustment? I click No as well as the documentation shuts.

I have composed a macro in Word as well as it functions each time I open SOME OF Word records. I don’t understand what is the factor for such an activity and also I wish to inquire you why?

Leave a Reply

Your email address will not be published. Required fields are marked *