News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

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.

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 175 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1059KB.
Tokens: post-login.
Cache hits: 13: 0.00218s for 26,722 bytes (show)
Cache misses: 3: (show)
Queries used: 16.

[Show Queries]