I want to check whether any excel instance is running at the time of opening my program. The following code is used.
Const ERR_APP_NOTRUNNING As Long = 429
On Error Resume Next
Set xlApp = GetObject("Excel.Application")
If Err = ERR_APP_NOTRUNNING Then
Set xlApp = Nothing
Exit Sub
Else:
Set xlApp = Nothing
MsgBox ("Sorry, please restart after closing all Excel files.")
End
End If
This code works fine in Office 2007. But its not working in Office 2010. Can someone help me out so that it may work on all office versions to date?