Hi, I don't know if that's the right place where asking this, but let's try.
I'm actually working on a Visio Draw wich have tons of icons to be changed manually from users (switching from an "active" state to a "passive" one).
I have been asked for automatize this process with vba, and i started out using Toggle Buttons, as ActiveX Image control's can't trigger click events in visio.
Basically I have Toggle Buttons with a picture loaded in, and change the state of the buttons switch the active and passive state of icons.
As I said, I have hundreds of toggle buttons in this draw and for each of them i would have to write the same macros, except for the Toggle Buttons property Names.
I am using this code for switching the picture in a single button:
and this code for call the one above clicking on the button:
I would have to copy this for every button, so I was looking for a way to "learn" the macro who switch the picture to look at wich button was pressed, so that I would have to copy only the click event macros that calls it.
I have tried different ways but I just can't look out how to refer to the toggle button name property on the code, nor how to derivate it from the last button clicked... I'm not so advanced on VBA and I usally use it for Excel and for basic function. I've read something about creating classes but I never went so deep on VBA programming, and I didn't untersand how do them work.
There is a way for give to a variable the property Name of the last clicked button? Or a way to copy a Toggle Button with all of his code, automatically changing the property Name inside of it?
Thank you very much, every tip is really appreciated.
I'm actually working on a Visio Draw wich have tons of icons to be changed manually from users (switching from an "active" state to a "passive" one).
I have been asked for automatize this process with vba, and i started out using Toggle Buttons, as ActiveX Image control's can't trigger click events in visio.
Basically I have Toggle Buttons with a picture loaded in, and change the state of the buttons switch the active and passive state of icons.
As I said, I have hundreds of toggle buttons in this draw and for each of them i would have to write the same macros, except for the Toggle Buttons property Names.
I am using this code for switching the picture in a single button:
VBA Code:
Private Sub TogglePicture1()
If ToggleButton1.Value = True Then
ToggleButton1.Picture = LoadPicture("C:\path\Active.jpg")
Else
ToggleButton1.Picture = LoadPicture("C:\path\Passive.jpg")
End Sub
and this code for call the one above clicking on the button:
VBA Code:
Private Sub ToggleButton1_Click()
Call TogglePicture1
End Sub
I would have to copy this for every button, so I was looking for a way to "learn" the macro who switch the picture to look at wich button was pressed, so that I would have to copy only the click event macros that calls it.
I have tried different ways but I just can't look out how to refer to the toggle button name property on the code, nor how to derivate it from the last button clicked... I'm not so advanced on VBA and I usally use it for Excel and for basic function. I've read something about creating classes but I never went so deep on VBA programming, and I didn't untersand how do them work.
There is a way for give to a variable the property Name of the last clicked button? Or a way to copy a Toggle Button with all of his code, automatically changing the property Name inside of it?
Thank you very much, every tip is really appreciated.