# Terminating a Word process from Excel VBA



## ging18 (Jan 16, 2007)

Hello All

I need to stop a Word process using an Excel macro.

Excel will create an instance of Word, use it and then close word. This works the majority of the time. When it does not work the Word process is still running in the background and needs to be stopped using task manager.

What I’m after is a way to terminate the instance of word created by excel.

I have found how to terminate all word instances but cannot workout how to close the one opened by the macro.

The terminate method will close a specific process ID but I cannot find a way of identifying the process ID of the instance of word created.

Does anyone have any idea how to Kill a specific Word process?

Any help or ideas will be greatly appreciated as this issue has about defeated my knowledge….

Thank you kindly
Christian


----------



## macropod (Apr 11, 2008)

Hi Christian,

Ordinarily, you'd have code like:
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
to initiate the Word session, then something like:
wrdDoc.Close False ' close the document without saving
wrdApp.Quit ' close the Word application
Set wrdDoc = Nothing
Set wrdApp = Nothing
to conclude the session. That way, nothing gets left behind. If you've got problems with some part of the process that's driven by Excel, you should ensure the Word session isn't created until it's actually needed and is closed immediately afterwards. The Word session should also have the ability to exit gracefully in the event of an error. Preferably, though, you'd track down and resolve the problem at its source.

Also, is your Office installation fully patched?


----------

