Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy macro to a new workbook - new question
Workbook 1 contains a push button. Attached to the push
button is a macro that performs a couple of edits and sends an e-mail. I have another macro that makes copies of the data in Workbook 1 for each business unit. Each copy contains the same push button. I copy a sheet from Workbook 1 with the code for the push button to the new workbooks. However, the macro attached to the push button is the macro from Workbook 1 and not the code on the new sheet. Here is the code I'm using to try and get the macaro attached to the push button in the new workbook: Workbooks(Wcount + 2).Activate Scount = Sheets.Count Workbooks(Wcount + 1).Activate Sheets("Sheet1").Select Sheets("Sheet1").Copy After:=Workbooks(Wcount + 2).Sheets (Scount) ActiveSheet.Name = "Sheet " & Scount + 1 Sheets("Sheet1").Select ActiveWorkbook.Names.Add Name:="Sheet4.ABC_Locations", RefersToR1C1:= _ "=""Rectangle 1""" ActiveSheet.Shapes("Rectangle 1").Select Selection.OnAction = "Sheet4.ABC_Locations" Any ideas or suggestions to make this code work would be great. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy macro to a new workbook - new question
ActiveSheet.Shapes("Rectangle 1").OnAction = Activesheet.codeName &
"!ABC_Locations" if the Macro is declared a Public -- Regards, Tom Ogilvy "JT" wrote in message ... Workbook 1 contains a push button. Attached to the push button is a macro that performs a couple of edits and sends an e-mail. I have another macro that makes copies of the data in Workbook 1 for each business unit. Each copy contains the same push button. I copy a sheet from Workbook 1 with the code for the push button to the new workbooks. However, the macro attached to the push button is the macro from Workbook 1 and not the code on the new sheet. Here is the code I'm using to try and get the macaro attached to the push button in the new workbook: Workbooks(Wcount + 2).Activate Scount = Sheets.Count Workbooks(Wcount + 1).Activate Sheets("Sheet1").Select Sheets("Sheet1").Copy After:=Workbooks(Wcount + 2).Sheets (Scount) ActiveSheet.Name = "Sheet " & Scount + 1 Sheets("Sheet1").Select ActiveWorkbook.Names.Add Name:="Sheet4.ABC_Locations", RefersToR1C1:= _ "=""Rectangle 1""" ActiveSheet.Shapes("Rectangle 1").Select Selection.OnAction = "Sheet4.ABC_Locations" Any ideas or suggestions to make this code work would be great. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copy one macro to another workbook | Excel Worksheet Functions | |||
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook | Excel Worksheet Functions | |||
Copy workbook, don't copy macro | Excel Discussion (Misc queries) | |||
Need a macro to copy a range in one workbook and paste into another workbook | Excel Programming | |||
Macro question: how to copy information from another workbook. | Excel Programming |