The different tools offered by the Microsoft Office suite allow us not only to create documents, but also to create functions. Of course this is for those programmers who know Visual Basic VBA Applications. But we are going to make it easy for you and in this article we are going to teach you how to close Word from a VBA code or Script- easy and fast.
But first we will reveal the question about what are Visual Basic Applications and this is nothing more than an application integrated in the Microsoft Office package.
This allows programming in the sheets of any document, be it Word, Excel, PowerPoint, Access and since it cannot be compiled, it becomes a macro and is distributed by simply copying the document.
Although this is an activity that is widely used by programmers, it does not prevent any mortal from learning to create functions using VBA Scripts. And we will give ourselves the task of teaching it quickly and easily. Since some terms can seem confusing and somewhat intimidating, like when you try to convert an OpenOffice document to Word .
How to close Word from a VBA script or code
One of its main uses has to do with automating repetitive or frequently used tasks such as this one, opening or closing a document created in Word .
Here are the steps you must apply to be able to close Word from a VBA code or Script . And to begin we enter the application from the desktop or wherever we have it saved.
The next step is important because you must have the Developer tab in the main menu, if this tab or tab is not shown, you must do the following. Hover over the Microsoft Office icon and click. This action will display a box with different options and you must go to the bottom of it and select Word Options.
Now a box will be displayed and on the left side of it you must choose the Most frequent option and on the right side in the Main options for working with Word section.
You are going to look for the option Show Developer tab in the Ribbon and when you locate it you must click on the check box on its left side to select it.
Steps to close Word from a VBA code or Script- Easy and fast
Once you have the developer tab on the ribbon, you can continue with the instructions that will allow you to close Word from a VBA code or Script.
The next step is to go to the main menu and select the Developer tab . Then in the Code section that is on the left side, you select the Visual Basic option.
The next step will be to write or paste the following code at the end of the line, Set objWord = CreateObject (“Word.Application”) Set objDoc = objWord.Documents.Close (“c: \ scripts \ test.doc ‘) objWord.Quit the next step will be to go to the upper left corner and click on the Microsoft Office icon .
Then you must choose the Save option and you will do it with the following name test.doc this with the VBA code that you will use to close the Word application.
You can see how simple and fast it is to perform programmer tasks. And use the Basic programming language which has a great similarity with other office packages such as OpenOffice and StarBasic.
And with this learning about programming language we have finished with the tutorial, but you may be interested in knowing more about the way in which programming source codes are inserted into a document. And so you can learn more about this little-explored point of the Word program.