s_woodbury
New Member
- Joined
- Feb 26, 2014
- Messages
- 27
Hey all, I'm trying to move a module to a new Workbook and assign it to a shape
I can Export/Import it but when I assign it I'm assigning the macro from the Original, not the New Workbook.
The New Workbook's name will change each time it's run. I don't know how to code a variable into the OnAction Line.
Here's the code I'm using any suggestions is appreciated. I'm stuck!
'Copy Module from ThisWorkBook to the path and folder of ThisWorkBook
MSRMaster.VBProject.VBComponents("Active_Customer_Filter").Export strTempFile1
'Copy the Module we saved earlier from ThisWorkBook to the New Workbook
Application.VBE.ActiveVBProject.VBComponents.Import (strTempFile1)
'Assign Macro to Shape already created
ActiveSheet.Shapes.Range(Array("Button 1")).Select
Selection.OnAction = "Active_Customer_Filter.bas"
I can Export/Import it but when I assign it I'm assigning the macro from the Original, not the New Workbook.
The New Workbook's name will change each time it's run. I don't know how to code a variable into the OnAction Line.
Here's the code I'm using any suggestions is appreciated. I'm stuck!
'Copy Module from ThisWorkBook to the path and folder of ThisWorkBook
MSRMaster.VBProject.VBComponents("Active_Customer_Filter").Export strTempFile1
'Copy the Module we saved earlier from ThisWorkBook to the New Workbook
Application.VBE.ActiveVBProject.VBComponents.Import (strTempFile1)
'Assign Macro to Shape already created
ActiveSheet.Shapes.Range(Array("Button 1")).Select
Selection.OnAction = "Active_Customer_Filter.bas"
Last edited: