Run Time 1004 error when calling sub from another macro

Curben

Board Regular
Joined
Aug 18, 2011
Messages
65
I am tryingto run a macro existing in another workbook opened by a variable, I am using the following code to try and get it to work but i get Run-time error '1004':

Cannot run the macro "Test 5.xlsm'!UpdTables'. The macro may not be available or all macros may be disabled.


Code:
Application.Run "'" & Application.ActiveWorkbook.Name & "'!UpdTables"
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Is the macro in a standard module (e.g., not in a sheet module)?
 
Upvote 0
Then, as shg is already suggesting, you'll need to place your UpdTables macro in a standard module.
 
Upvote 0
I'm assuming that...

1) macros have been enabled, and;

2) 'Test 5.xlsm' contains the UpdTables macro.

Is this correct?
 
Upvote 0
Both assumptions are correct. I can run the macro from within the (test 5)workbook itself, but not when called from the other workbook (Test Master)
 
Last edited:
Upvote 0
Hi

When it bugs out, what does this return when entered in the Immediate Window of the VBE (open this up with Ctrl+g if you have to):

?"'" & Application.ActiveWorkbook.Name & "'!UpdTables"

Don't miss the leading ? above. Does this tally with what you expect (ie is the workbook name correct)?
 
Upvote 0
1. Are you sure that the workbook that contains the macro is active when you execute the statement?

2. Does your statement work if you put in the workbook that contains the macro, with that worbook active?

Code:
Application.Run "'" & Application.ActiveWorkbook.Name & "'!UpdTables"
 
Upvote 0
That helped me find the ID-10-T error
Trying things on my own I switched from
Code:
Application.Run "'" & Application.ActiveWorkbook.Name & "'!UpdTables"
TO
Code:
Application.Run Application.ActiveWorkbook.Name & "!UpdTables"


the test you gave showed me the slight syntax difference and I reverted the call, it works now thanks everyone.
 
Upvote 0

Forum statistics

Threads
1,212,927
Messages
6,110,697
Members
448,293
Latest member
jin kazuya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top