View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default On Error doesn't trap Application.Run error

blackhawk,
Do you have "Break On All Errors" checked, under ToolsOptionsGeneral ?

See this recent thread in "microsoft.public.vb.general.discussion" for an
explaination of the different settings.

From: "Gerald Hernandez"
Subject: Why don't I get an error here?
Date: Thu, 3 Mar 2005 16:54:45 -0700

NickHK

"blackhawk" wrote in message
...
I have a macro in an XLA that is trying to run a macro in a different
workbook, if the macro does not exist, I just want to ignore it and

continue,
otherwise run it.

It works fine if the macro exists, but if it doesn't I get the runtime

1004
error dialog box, and no matter what I do, I cannot seem to prevent it.
Here is a sample of my code:

Public Sub RunMacro( FileName )
On Error GoTo Finish
Set ReportWorkbook = Workbooks.Open(FileName, , True)
Application.Run ReportWorkbook.Name & "!Execute"
On Error GoTo 0
Finish:
End Sub

Am I missing something here????