Link to home
Start Free TrialLog in
Avatar of tchristie33
tchristie33

asked on

Insert a button for an entire workbook in excel 2003

I am trying to insert a button on to a specific worksheet in my automated excel report. However, whenever i try to insert a button it based the buttom off of that particular sheet and I don't want it to do that. I want the button to be based off of the entire workbook like it is very easy to do in Excel 2007. How do i play a button on one sheet that references a macro in my module for the entire workbook? Thanks for the help.
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

I'm a little confused by your question, but I think you are looking for the Button control from the Forms toolbar. You are able to attach any public macro from any workbook (basically, any macro visible when pressing Alt+F8).

Wayne
Hi christie,
read
How to dynamically add and run a VBA macro from Visual Basic
http://support.microsoft.com/kb/219905
I hope this helps
wbr
Janos

Avatar of tchristie33
tchristie33

ASKER

I know how to insert a button in excel for my vba code.....the problem is that once i insert a button in excel 2003 it will only allow me to put code into the button from that worksheet of which the button is located. I want to be able to have a button that runs off of code in a module within the entire workbook and not just an individual sheet. Does this make sense as to what i am asking? thanks
Which type of button are you adding? From the Control Toolbox or Forms toolbar? If you use one from the Forms toolbar, a macro in a regular module can be attached. Control Toolbox buttons run code in the worksheet's module.

Wayne
add your macro like this below and you can call here an other macro (here it is MyMacro) which is located on a module sheet

Private Sub CommandButton1_Click()
    MyMacro
End Sub

wbr
Janos
wettubbs

I think that what you are saying sounds right. How do i get to the forms toolbar though? The control toolbox is the only one i can get to show up?

kacor-
I have tried that and it will work however, when doing it that way your enitre code has to be written a different way since you can't select a sheet and then write code off of that every line of code that is not on the worksheet where the button is located must reference the other worksheet (on every line of code) hope that makes sense. All in all that way does not work
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial