LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Error Handling Problem calling Macro from Other Worksheet

Hi,
got a problem trying to catch a error when i'm calling a macro from
another workbook using the
Application.Run statement. My code is like this:

Public Sub OpenFileMacro(file_name)

On Error Goto Error
Worbooks.open file_path & file_name ' Open the file
Workbooks("file_name").Activate 'focus to the worksheet
Sheets("sheet_name").Select 'select the target
sheet for the macro
Application.Run (file_name!Macro1) 'Run macro1 from the
worksheet.

Error:
ActiveCell.Offset(0, 1).Value = "Can't Open file or Macro is failing"
'message to write in a cell
For Each oWkBook In Workbooks ' close wb if is
open
If UCase(oWkBook.FullName) = UCase(file_name) Then
Workbooks(file_name).Close savechanges:=False
Exit For
End If
Next
exit sub
End Sub

The code runs from a macro in another workbook with the filenames.
I want to determine which files can run the macro and which can't
writing in a cell in the wb with the filenames.

Can anybody help me?

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error handling problem Jim G Excel Discussion (Misc queries) 2 October 3rd 07 02:19 AM
Problem with handling on error when file is already open Frank Excel Programming 3 September 22nd 06 04:26 PM
Error Handling problem Brassman[_5_] Excel Programming 3 May 24th 05 03:43 PM
Error Handling Problem Minitman[_4_] Excel Programming 3 November 15th 04 06:52 AM
Excel VBA - Error handling problem brutalmetal[_2_] Excel Programming 2 January 21st 04 03:17 AM


All times are GMT +1. The time now is 11:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"