Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy one macro to another workbook Jay Excel Worksheet Functions 2 September 4th 08 06:03 PM
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Copy workbook, don't copy macro CongroGrey Excel Discussion (Misc queries) 1 June 13th 08 04:56 PM
Need a macro to copy a range in one workbook and paste into another workbook Paul Excel Programming 8 July 1st 04 07:42 AM
Macro question: how to copy information from another workbook. Paul Excel Programming 0 September 7th 03 07:19 PM


All times are GMT +1. The time now is 09:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"