Author Topic: Using Shape as a parameter  (Read 2069 times)

0 Members and 1 Guest are viewing this topic.

tom.stein

  • Newbie
  • *
  • Posts: 2
Using Shape as a parameter
« on: August 23, 2016, 12: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:

Code
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

  • Hero Member
  • *****
  • Posts: 2991
Re: Using Shape as a parameter
« Reply #1 on: August 23, 2016, 12: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.
Yacine

tom.stein

  • Newbie
  • *
  • Posts: 2
Calling a sub with parameters
« Reply #2 on: August 23, 2016, 12:47:57 PM »
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.