Get Visio Shape Properties

B

bryan.benway

I currently have a network map in Visio where I have macros setup on
the double click of a network item such as a router.

The current script is:

Sub Telnet()
x = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler
telnet://10.100.1.1", vbNormalFocus)
End Sub

Which opens up a terminal session to the device.

In Visio, the Shape has an custom property that I want to pull into the
function so when I double click each router, I can reference the same
function and not have to hard code the IPs into each sub
 
A

Al Edlund

I just put this into a hyperlink, but you probably get the idea
"""TELNET:""&Prop.Ipaddress"
al
 
M

Michel LAPLANE

Look at the sdk help and use the CALLTHIS function you can pass some
parameters. The content of the EventDblClik cell could be
"CALLTHIS("ThisDocument.RunWithArg",,Prop.Row_1).
And the vba could be
Sub RunWithArg(shpObj as Visio.Shape,ipAddress as string)
MsgBox "This is my IP Address" + ipAddress
end sub

If the Prop.row_1 contain your ipadress it with work.
 
B

bryan.benway

Can someone post a modified Sub that I can use. I dont think i follow
100% what you both are saying but thanks so much for the replies.
 
M

Michel LAPLANE

1. Add a custom property to your router shape and call it "IpAddress".
2. Open the shapesheet of the shape and look the line name of the custom
property you have added. let say that visio has named it "Prop.Row_1"
3. Go to the event section and type
CALLTHIS("ThisDocument.RunWithArg",,Prop.Row_1) in the EventDblClick cell
4. Open the VBA editor and create this sub :
Sub Telnet(shpObj as Visio.Shape, ipAddress as string)
' call your process with the arg ipAddress
x = Shell .....
End sub.
5. Save and double click on the shape to test

<[email protected]> a écrit dans le message de (e-mail address removed)...
Can someone post a modified Sub that I can use. I dont think i follow
100% what you both are saying but thanks so much for the replies.
 
B

bryan.benway

Ok. I created the shape nad it has the property Prop.IPAddress and the
value is set to an IP, say 192.168.1.1.

Now in the shapesheet, I have in the EventDoubleClick:
CALLTHIS("ThisDocument.RunWithArg",,Prop.IPAddress)

Finally, in the vba script I have:
Sub Telnet(shpObj As Visio.Shape, ipAddress As String)
x = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler
telnet://ipAddress", vbNormalFocus)
End Sub


Where do I tell the EventDoubleClick to run the Telnet subroutine
because on the doubleclick its not running anything.
 
M

Michel LAPLANE

As you subroutine is called "Telnet", Instead You must put in the event
doubleClick this formula "CALLTHIS("ThisDocument.Telnet",,Prop.IPAddress)".
To see if it work add MsgBox in you subroutine :
Sub Telnet(shpObj As Visio.Shape, ipAddress As String)
MsgBox ipAddress
x = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler
telnet://ipAddress", vbNormalFocus)
End Sub

<[email protected]> a écrit dans le message de (e-mail address removed)...
Ok. I created the shape nad it has the property Prop.IPAddress and the
value is set to an IP, say 192.168.1.1.

Now in the shapesheet, I have in the EventDoubleClick:
CALLTHIS("ThisDocument.RunWithArg",,Prop.IPAddress)

Finally, in the vba script I have:
Sub Telnet(shpObj As Visio.Shape, ipAddress As String)
x = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler
telnet://ipAddress", vbNormalFocus)
End Sub


Where do I tell the EventDoubleClick to run the Telnet subroutine
because on the doubleclick its not running anything.
 
B

bryan.benway

ipAddress is still set to nothing when it runs..

I think it has to do something when im pulling the arg from my
Prop.IPAddress and then im not giving it a value in my subroutine but
how do you do that?

CALLTHIS("ThisDocument.Telnet",,Prop.IPAddress)
 
M

Michel LAPLANE

If you do exactly these things it must work. Verify that the name of your
custom property is correct : Open the shapesheet of the shape and verify
that in the custom properties section the line containing your custom
property is named "Prop.IPAddress.
When you fire the event visio automatically pass the value to your sub you
do not have to do more :

1. Add a custom property to your router shape and call it "IpAddress" as
Label and "IpAddress" as Name and let the default type string.
2. Open the ShapeSheet of the shape and look the line name of the custom
property you have added.Visio must have named it "Prop.IpAddress"
3. Go to the event section of you router and type
CALLTHIS("ThisDocument.Telnet",,Prop.IpAddress) in the EventDblClick cell
4. Open the VBA editor and create this sub :
Sub Telnet(shpObj as Visio.Shape, ipAddress as String)
MsgBox "My ip address is " + ipAddress
End sub.
5. Save
6. Fill the custom property with "192.168.1.1" and double click on the
shape, a message box must appear with the message "My ip address is
192.168.1.1".


<[email protected]> a écrit dans le message de (e-mail address removed)...
ipAddress is still set to nothing when it runs..

I think it has to do something when im pulling the arg from my
Prop.IPAddress and then im not giving it a value in my subroutine but
how do you do that?

CALLTHIS("ThisDocument.Telnet",,Prop.IPAddress)
 

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