Using Shape as a parameter

Started by tom.stein, August 23, 2016, 05:32:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tom.stein

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?
Used to computers since 1983 - but still finds new bugs in his brain. Not very experienced in Visio-VBA.

Yacine

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.
Yacine

tom.stein

Thanks. It was so obvious - and the error message was so erroneous. Problem solved.
Used to computers since 1983 - but still finds new bugs in his brain. Not very experienced in Visio-VBA.