Calling shape data fields into a macro

Started by jweathers, March 18, 2022, 06:19:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jweathers

I have a macro that opens an ssh session when an object is clicked on (in my case a Cisco switch object).  The problem is that I don't know how to make it universal so that I can click on any switch in my diagram and have it open an SSH session to that switch.

Here is my macro now, which will only open the putty session named "SWITCH1":

Sub SSH()

Call Shell(C:Program Files\PuTTY\putty.exe -load SWITCH1")

End Sub



Pretty simple, but I need to replace SWITCH1 with the contents of the Prop.NetworkName shape data field so it will open whichever switch I double-click

What lines do I need to add to extend the functionality of my macro to use the contents of the Prop.NetworkName field instead of the hard-coded SWITCH1 name?

By they way, for anyone else that may want to do this, putty needs to be pre-configured with saved sessions with the switch names, in this case SWITCH1, 2, 3, etc.

Thanks in advance...

Surrogate

Hi,

I haven't PuTTY now and cant check this solution. Please try this way
Add formula CALLTHIS("<Module name>.<Sub-routine name>",,Prop.NetworkName) for your Cisco switch shape in cell EventDblClick
In your case <Sub-routine name> is SSH.

Remove your routine to
Sub SSH(shpObj As Visio.Shape, prop As String)
Dim ShellStr as String
ShellStr = "C:Program Files\PuTTY\putty.exe -load " & prop
Call Shell(ShellStr)
End Sub

jweathers

Whenever I add that first line the macro disappears from the list (open Macros, no longer there)