Looking for an example of CALLTHIS in Visio

92 Views Asked by At

I won't list the many many permutations I tried that did not work.

My goal is to call a subroutine that takes the caller's name as an argument.

Something like:

Public Sub Shape_DoubleClick(ByVal shapeName As String)
    Debug.Print "Shape_DoubleClick called for: " & shapeName
End Sub

But no matter what I write into the EventDblClick cell of the ShapeSheet, I do not see any activity.

I can not get anything that involves CALLTHIS to work in Visio. Can anyone show me an example?

1

There are 1 best solutions below

0
Surrogate On

My goal is to call a subroutine that takes the caller's name as an argument.

Argument of called function must be Shape Object, not string!
Please read more in Remarks for CALLTHIS function description.


You can change your code like:

Public Sub Shape_DoubleClick(ShapeObj As Shape)
    MsgBox "Shape_DoubleClick called for: " & ShapeObj.Name
End Sub

And formula in EventDblClick cell must be like: CALLTHIS("ThisDocument.Shape_DoubleClick")

UPDATED:
You can combine Shape object and string arguments:

Public Sub Shape_DoubleClick(vsoShape As Visio.Shape, shapeName As String)
   MsgBox "Shape_DoubleClick called for: " & shapeName
End Sub

For run this routine use formula: CALLTHIS("ThisDocument.Shape_DoubleClick",,NAME())

Please read more about CALLTHIS in article Using the CALLTHIS function in Visio by David J Parker!