Copying Macros
Hi there,
I am having a problem copying a worksheet which has several macros (buttons) on it.
When I copy the worksheet, the buttons loose the link to the code I have created.
Can anyone tell me how I copy a worksheet, and keep the macros (buttons) linked to the code, without having to manual assign the code.
Thanks in Advance
[365 byte] By [
NWright] at [2007-11-11 11:58:00]

# 1 Re: Copying Macros
Welcome to dev-archive :WAVE:
How do you copy it? Are you using Windows Explorer to do the copy or are you doing it through code?
Hack at 2007-11-11 17:20:57 >

# 4 Re: Copying Macros
I have listed the code I am using below. This only moves the sheet will all information attached to it but does not copy my buttons with the assigned code.
Sheets("System 1").Select
ActiveSheet.Buttons.Add(47.25, 75.75, 97.5, 28.5).Select
ActiveSheet.Buttons.Add(47.25, 120, 97.5, 28.5).Select
ActiveSheet.Buttons.Add(48, 165.75, 97.5, 28.5).Select
ActiveSheet.Buttons.Add(48, 210.75, 97.5, 28.5).Select
ActiveSheet.Buttons.Add(49.5, 256.5, 97.5, 28.5).Select
Sheets("Editing...").Copy After:=Sheets(9)
This has been really annoying me for a while now.
Thank you in Advance
# 5 Re: Copying Macros
Can you use a binary data copy ? I mean copy the file itself without copying element by element ? or you just want to copy specified objects ?
and what r u using .. VB or VBA ? because I thing your method copy the object "button" but doesn't copy its events ..
Amahdy at 2007-11-11 17:24:56 >

# 7 Re: Copying Macros
Hack,
You are right. That is exactly what I need to do.
I apologise for any misunderstandings, I am reletivly new to VBA.
I do believe that my code does copy the button across but like it says above not the events. This is what I need to do
Thank you in Advance