Friday, April 9, 2010

VBScript - Connect to/Start Microsoft Excel

Connect to/Start Microsoft Excel (Starts a new instance of Excel, but only if Excel is not already running. Avoids multiple instances of Excel from running. )

On Error Resume Next
set xlApp = GetObject(, "Excel.Application")
If Err.Number <> 0 then
'MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description)
Err.Clear
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "excel.exe"
Else
xlApp.Visible = True
End if

[Via]