Visio 2002 - Passing Object ID to Macro

J

John Sawyers

I am using the Blank Button Object from the Windows User Interface stencil to
develop a GUI screen.

I want to be able to click on the object and change the background and font
color.

Because there are mulitple button objects on the page, I would like to use a
single macro to read what button object was clicked on and only change that
object.

I'm VERY new to Visio VBA so any help would be appreciated.

Thanks...John
 
C

Chris Roth [Visio MVP]

Hi John,

First off, the button shape is just a shape, it's not a real windows GUI
control object.

So if you want something special to happen when you click on it, then
how will you move or resize the button as a Visio shape?

There are plenty of ways to do something to your shape, don't worry,
it's just that your question might not be so clear to us.

But anyway...

You could just operate on selected shapes on a page. You can get the
shapes that are selected in a Visio window like this:

Dim sel as Visio.Selection
Set sel = Visio.ActiveWindow.Selection
Dim shp as Visio.Shape
For Each shp in sel
'Do something to the shp object
Next shp


You could add a formula to the EventDblClick cell of each button's
ShapeSheet. When the user double-clicks on a button shape, the formula
will execute. If you link a formula to some VBA code with the CALLTHIS
function, then you can get some stuff to happen:

First the ShapeSheet formula:

Events.EventDblClick = CALLTHIS("ThisDocument.DoSomething",)

Then some supporting VBA code in the ThisDocument module:

Sub DoSomething( visShp As Visio.Shape)

MsgBox "The shape is: " & visShp.ID

End Sub


--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People

Articles: http://www.visguy.com
Shapes: http://www.visguy.com/shapes
Dev: http://www.visguy.com/category/development/
Forum: http://www.viguy.com/vgforum
 
J

John Sawyers

Hey Chris,

Thanks for the reply. Your response told me everything I was asking for.
You got me pointed in the right direction.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top