Hi,
I have a workbook, 'MyWb.xls' and a sheet with buttons to which I attach some sheet macros.
When I assign a macro to a button I pick the appropriate reference, e.g. Sheet2.MyMacro, and this gets recorded by default as MyWb.xls!Sheet2.MyMacro
When I create a new single sheet workbook with the instruction ActiveSheet.Copy, I end up with a new workbook, say 'Book2' along with the buttons as expected. However the macros attached to the buttons still refer to the MyWB.xls file and not the new 'Book2.xls'.
As part of the process of creating the new book I've tried redefining the macro with the instruction
but this doesn't change anything and I'm left with the reference back to the MyWb.xls macro, which of course is no use when the new book gets distributed.![]()
Please Login or Register to view this content.
Can anyone suggest a solution?
I've looked at putting the sheet macros in a procedure at the Module level, and then first exporting the module as a .bas file and re-importing it to the new book, but this seems unnecessarily complicated, and in any case if the Application does not have the Macro Security set to 'Trust Access to the Visual Basic Project' this won't work, and of course this setting can't be set programatically.
All ideas gratefully received,
Regards
Bookmarks