Friday, April 9, 2010

This VBScript code tells you if Excel is running, and makes the first instance it finds visible.

This VBScript code tells you if Excel is running, and makes the first instance it finds visible.

Copy this code into a text file, and save it in a convenient folder or on your desktop with a name like 'XLcheck.vbs'. When you think you've left an invisible instance of Excel running, run this (by double clicking) to make it visible, so you can deal with it.


' XLcheck.vbs
' Find an invisible instance of Excel
' from Rob Bruce

Dim objXL, strMessage

On Error Resume Next

' Try to grab a running instance of Excel:
Set objXL = GetObject(, "Excel.Application")

' What have we found?
If Not TypeName(objXL) = "Empty" Then
strMessage = "Excel Running."
Else
strMessage = "Excel Not Running."
End If

' Feedback to user...
MsgBox strMessage, vbInformation, "Excel Status"

' Make it show so we can kill it
if strMessage = "Excel Running." then objXL.Visible = true

' End of VBS code

[Via]