Vbscript Close Program Gracefully
Handy-Dandy Scripts: closing Word gracefully. 2 minutes to readIn this articleSometimes you may find winword.exe process lingering in the memeory and there is no visible Word window that allows you to close it. Believe me, this mostly likely is not Word's fault: chances are that those ghost Word instances are started by some third party applications via automation. But for some reason those applications are not able to terminte the Word instances they brought up.Now aside from blaming third party applications, what can you do to close Word gracefully? You certainly could kill the process from task manager or other process managing applications. But that is not something called 'gracefully': for one thing setting changes you made to Word may get lost. Second if the killed Word instance has modified document open, you will be greeted by the 'Document Recovery' taskpane next time you starts Word.In case you don't know, the trick is to use GetObject to connect to the existing Word Application COM object.
Vbscript Close Program Gracefully 2017
Running a simple vbscript like the one below should do the job:On Error Resume NextDoSet wd = NothingSet wd = GetObject(, 'Word.Application')If Not wd Is Nothing Thenwd.Quit 0 'wdDoNotSaveChangesElseExit DoEnd IfLoopWarning: the above script will force Word to quit without saving any changes. If you have unsaved but important changes pending in a 'ghost' Word instance, you should use GetObject to connect to the instance first, then save your changes with Word object model. Recommended Content.