Need Visio macro Visual Basic code assistance

D

Dwoeltje

I need to create a macro in Visio that I can set the Double-click behavior of
an object to run. I tried using the macro recorder....but when I'm done and I
stop recording and I do an edit on the Macro to see the code, it didn't put
any code into the macro. So, when I set the double-click behavior of that
object to run that macro, and then I double-click that object, nothing
happens.

What I tried to record with the Macro Recorder is to simply right-click that
same object and then click properties. Very simply, I want someone viewing my
network diagram to be able to double-click on an object, say a server object
(for example), and the properties of that object will pop up so that they can
view those properties.

Since the Macro Recorder doesn't seem to be able to create the macro
correctly, I need to know what code to insert into the macro that will cause
the object's properties to be displayed. Can anyone help me with this?
 
J

John Goldsmith

You can use the DOCMD(1312) function in the Events section of the
ShapeSheet. An example of a procedure that adds this to every shape on the
active page would be as follows:

Public Sub AddDoubleClicks()
Dim shp As Shape
For Each shp In ActivePage.Shapes
shp.CellsU("EventDblClick").FormulaU = "=DOCMD(1312)"
Next shp
End Sub

Obviously you might want to add other conditional statements if you don't
want to apply it to every shape.

Take a look at this post on the DOCMD() function.

You might also find this blog post useful for getting going on macros and
VBA - http://visualsignals.typepad.co.uk/vislog/2007/10/just-for-starte.html

Best regards

John


John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
D

Dwoeltje

I appreciate your attempt to help me and I'm sure many people can come up
with many different ways to accomplish what I want to do.....bvut I only want
to do it my way. As you said, I DON'T WANT TO APPLY THIS TO ALL MY OBJECTS.
Nor do I want to have to come up with code to tell it to except other
objects. All I want is to be able to right click on a specific object to pull
up its context menu, click on Behavior, and set the Double-Click behavior to
run a macro.

I want THE MACRO to cause the objects properties to be displayed. So, I
double-click the object, the macro runs, and the objects properties get
displayed. I DON'T want to do it any other way. I need to know what code to
put into my macro to do it THAT way.
 

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