ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding a macro to all new workbooks (https://www.excelbanter.com/excel-programming/374948-adding-macro-all-new-workbooks.html)

AndrewArmstrong

Adding a macro to all new workbooks
 
I have a master workbook that creates other workbooks via VBA. Each new
workbook has a forms toolbar button. I have assigned a macro to the
button using

Set btn = ActiveSheet.Buttons.aDD(460, 1, 100, 25)
btn.OnAction = "AddInterface"
btn.Characters.Text = "Add Interface"

This seems to reference back to the macro on the sheet that is creating
the workbook. I would like each new workbook to contain a module with
the VBA code I have written, called "AddInterface", that does not
require the master sheet. Any ideas?? Thanks in advance!


Bob Phillips

Adding a macro to all new workbooks
 
Create a template with that code, and when adding workbooks, use the
template

Workbooks.Add template_path_and_name

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"AndrewArmstrong" wrote in message
ups.com...
I have a master workbook that creates other workbooks via VBA. Each new
workbook has a forms toolbar button. I have assigned a macro to the
button using

Set btn = ActiveSheet.Buttons.aDD(460, 1, 100, 25)
btn.OnAction = "AddInterface"
btn.Characters.Text = "Add Interface"

This seems to reference back to the macro on the sheet that is creating
the workbook. I would like each new workbook to contain a module with
the VBA code I have written, called "AddInterface", that does not
require the master sheet. Any ideas?? Thanks in advance!




AndrewArmstrong

Adding a macro to all new workbooks
 
Thanks Bob! I'll give it a shot and let you know how it turns out. I
really appreciate the help!



All times are GMT +1. The time now is 03:40 AM.

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