ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run macro in different workbooks (https://www.excelbanter.com/excel-programming/290885-run-macro-different-workbooks.html)

netzig

Run macro in different workbooks
 
I am trying to run a macro that originates in an Excel template file. So before the macro is run the file is saved with a certain name. The name of the workbook is then retrieved and built into a string to create the name of the macro and then the command calls the macro. When I run this right in the Excel template file, it will run, however when I run it in a workbook that was created based on the template, the method fails

Code

Dim ThisFile As Workboo
Set ThisFile = ActiveWorkboo
WkbkName = ThisFile.Nam
MacroString = WkbkName & "!make_final_but
ActiveWorkbook.Application.Run MacroString


All times are GMT +1. The time now is 12:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com