brothertruffle880
asked on
Visio VBA - Assigning 4 macros to 4 buttons throughout a visio file
I would like to have four macro buttons on every page of my 23 page visio file.
CommandButton1_click()
CommandButton2_click()
CommandButton3_click()
CommandButton4_click()
I attached code to each command button click event and they all work on one page but when I copy those same four buttons to another page. I get command button5, 6, 7, 8.
When I try to rename the newly pasted button from command button5 back to commandbutton 1, I get "Ambiguous Name Detected Command Button 1"
I don't want to reprogram or copy code over and over again.
I want to invoke those same four code modules regardless of what page they're on.
CommandButton1_click()
CommandButton2_click()
CommandButton3_click()
CommandButton4_click()
I attached code to each command button click event and they all work on one page but when I copy those same four buttons to another page. I get command button5, 6, 7, 8.
When I try to rename the newly pasted button from command button5 back to commandbutton 1, I get "Ambiguous Name Detected Command Button 1"
I don't want to reprogram or copy code over and over again.
I want to invoke those same four code modules regardless of what page they're on.
ASKER
Doesn't matter what the buttons are called but I'm trying to avoid typing code over and over.
or pasting code over and over I have 28 pages. multiply that by four buttons 28 x 4 = 112 event procedures!
Here is the code I want to attach to each button:
Of course MGMT$ will change because each button will invoke a different layer.
or pasting code over and over I have 28 pages. multiply that by four buttons 28 x 4 = 112 event procedures!
Here is the code I want to attach to each button:
Dim pg As Visio.Page
Set pg = Visio.ActivePage
Call m_showAndHideLayers(pg, LayerName_Mgmt$)
Set pg = Nothing
Of course MGMT$ will change because each button will invoke a different layer.
Dim pg As Visio.Page
Set pg = Visio.ActivePage
Call m_showAndHideLayers(pg, LayerName_Wireless$)
Set pg = Nothing
etc.
got it. didn't know you were referencing the current page in your code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi CodeCruiser
This is a useful solution and I will use it But my problem is different.
I have awarded you the points because it's a terrific piece of code.
This is a useful solution and I will use it But my problem is different.
I have awarded you the points because it's a terrific piece of code.
e.g.
CommandButton1_click()
functionA()
CommandButton2_click()
functionA()
CommandButtonNN_click()
functionA()