Passing arguments from Visio Shapesheet to procedure in VBA not working

Started by alexiscg, March 18, 2021, 06:15:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

alexiscg

I have been working with Visio VBA for a couple of years and I constantly pass arguments from the ShapeSheet of a shape to several procedures in VBA using either RUNMACRO() or CALLTHIS() Functions. I either pass pass plain strings or the value of different formulas in the ShapeSheet. The most common argument that I pass to my procedures is the ID() of the shape. The issue that I am facing is that for some reason after I received a patch update of windows: https://support.microsoft.com/en-us/topic/march-15-2021-kb5001566-os-build-18363-1441-out-of-band-23c4c824-8638-43e9-a381-ff58213ae6fe , I am no longer able to pass arguments from the ShapeSheet of a Shape to my procedures in VBA. Whenever I use RUNMACRO or CALLTHIS, all the arguments that I pass, even if they are plain strings, in my procedure side everything that I get is "", blank information. Is there a way to know if this is just a bug or if this something that on purpose is staying in Visio VBA, maybe as a security measure. Must of my procedures are based on passing arguments from the ShapeSheet Shape to my VBA procedures and this issue is definitely putting me in a really bad spot, I was hoping that someone can help me with this.
Here is a simple example procedure:

Public Function HelloWorld(Number As Integer)
   
    If Number = 1 Then
   
      MsgBox ("Hello World 1")
   
    End If
   
    If Number = 2 Then
   
      MsgBox ("Hello World 2")
   
    End If
   

End Function
And this procedure is called in the EventDblClick of a Shape:

RUNMACRO("HelloWorld(1)","Test")
When the EventDblClick is triggered the value of Number stays as null, ignoring completly the argument sent in the RUNMACRO function, which is a 1. Since the argument of Number in the HelloWorld() function is not optional, it triggers an "Argument not optional" Compile error message.

Visisthebest

I don't use arguments (yet) with CALLTHIS() but interesting to know if this issue is replicated, certainly a Windows patch should not cause such changes in behavior hopefully something else is causing this.
Visio 2021 Professional

Surrogate

Quote from: Visisthebest on February 24, 2021, 09:19:19 AM
I use CALLTHIS a lot, so good to see this explanation and example of using CALLTHIS:
https://bvisual.net/2021/02/22/using-the-callthis-function-in-visio/
sub-routine which fired by callthis function must have shape related argument!
Quote from: Surrogate on January 10, 2021, 01:15:58 PM
Sub-routine which call via CALLTHIS must have parameters


from Visio 2002 Developer's Survival Pack (by Graham Wideman)

Visisthebest

Yes Surrogate but you don't need to add the shape as an argument in an Action cell, you always get the shape calling the sub as an argument. I don't use any additional arguments that I add explicitly (yet).
Visio 2021 Professional