Identifying if WINWORD.EXE is running (Office 2010)

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Identifying if WINWORD.EXE is running (Office 2010)

Post by Jack21 »

Hi - can anyone help?

On opening a Windows Application Form I need to identify if WINWORD.EXE is running before I action any code. Is there a way to check if the application is open?

Thanks
Jack

User avatar
Leif
Administrator
Posts: 7210
Joined: 15 Jan 2010, 22:52
Location: Middle of England

Re: Identifying if WINWORD.EXE is running (Office 2010)

Post by Leif »

Leif

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Re: Identifying if WINWORD.EXE is running (Office 2010)

Post by Jack21 »

Thanks Leif .... works like a charm.

I stand corrected - it's not exactly what I'm after. The issue I have is that certain documents are causing Word 2010 to hang, the user will then close Word but WINWORD.EXE stays open in the taskpane. I need to identify if WINWORD.EXE is open before ending the process so I can run the necessary code to repair the document that is causing Word 2010 to hang.

Any ideas?

Cheers
Jack

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Re: Identifying if WINWORD.EXE is running (Office 2010)

Post by Jack21 »

This works guys .... just in case anyone needs it in the future:

Dim strComputer As String = "."
Dim strProcessKill As String = "'winword.exe'"
Dim objWMIService As Object = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Dim colProcess As Object = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " & strProcessKill)

For Each objProcess As Object In colProcess
objProcess.Terminate()
Next

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Identifying if WINWORD.EXE is running (Office 2010)

Post by HansV »

Thanks for sharing the solution!
Best wishes,
Hans

User avatar
John Gray
PlatinumLounger
Posts: 5411
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Identifying if WINWORD.EXE is running (Office 2010)

Post by John Gray »

It's a one-line BATch file, if anyone is interested!
John Gray

"(or one of the team)" - how your hospital appointment letter indicates that you won't be seeing the Consultant...