98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Running a macro from another workbook
Running a macro from another workbook
Resolved · High Priority · Version 2010
Chris has attended:
Excel VBA Introduction course
Excel VBA Intermediate course
Excel VBA Advanced course
Excel Forecasting and Data Analysis course
Running a macro from another workbook
Hi guys,
I am trying to create a macro that opens certain workbooks and triggers a macro to run, but I am having some problems.
I have written the below code. Which I though would work but no joy...
_____________________________________
Sub OpenAndRun ()
Workbooks.Open ("FilePath and FileName.xlsm")
Application.Run ("'FilePath and FileName.xlsm'!MacroName")
End Sub
______________________________________
The file opens as expected, but the macro will not run. Instead I get the below error message.
________________________________
Run-time error '1004':
Cannot run the macro 'FilePath and Macro Name'.
The macro may not be available in this workbook or all macros may be disabled.
________________________________
Please help!!
RE: Running a macro from another workbook
Hi Chris,
Thank you for the forum question.
I cannot see that you are doing something wrong. I copied your to lines and just did it between two test workbooks and it worked fine.
Well if the macro in the workbook is private then you cannot do it.
If the macro you try to execute starts:
Private Sub MacroName()
code to run
End Sub
If you want I can have a look at the workbooks.
You can send them to:
info@stl-training.co.uk
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Make a quick copy of a worksheetHold down the Ctrl key, then click and drag on a sheet tab to make a copy of that sheet. Though this process usefully copies the formats of the original sheet, note that any Range Names you have on the original sheet will be duplicated too. |