Visio Guy

Visio Discussions => Shapes & Templates => Topic started by: tom.stein on August 23, 2016, 05:32:49 PM

Title: Using Shape as a parameter
Post by: tom.stein on August 23, 2016, 05:32:49 PM
Hi,
I'm quite new to Visio VBA and have a problem that is so simple - I can't find the answer. The following code gives a compilation error "Type mismatch" in marked line:

Private Sub MakeShapeRed(myShp As Visio.Shape)
    ' Just do something magical with this shape
End Sub

Private Sub MakeAllShapesRed(myShape As Visio.Shape)
Dim myGroupShape As Visio.Shape

    MakeShapeRed (myShape)      ' Do some magic to this shape, but this gives a TYPE MISMATCH
    For Each myGroupShape In myShape.Shapes
        MakeAllShapesRed (myGroupShape)  ' and recursive for groups
    Next myGroupShape
End Sub


Can anybody open my eyes, please?
Title: Re: Using Shape as a parameter
Post by: Yacine on August 23, 2016, 05:40:11 PM
remove the brackets from the parameters of subs.
functions require them, subs only work without.
haven't understood the philosophy behind this convention, but that's how it works.
Title: Calling a sub with parameters
Post by: tom.stein on August 23, 2016, 05:47:57 PM
Thanks. It was so obvious - and the error message was so erroneous. Problem solved.