What am I doing wrong here ?

L

Lee Bassom

Hi all,
I'm hoping someone can help me out with a bit of VBA in Visio.

It looks ok, but I'm getting a type mismatch error :(
(It's just a simple bit of code I'm using to figure out how to do something)

Public Sub callDummy()
Dim shp As Visio.Shape
Set shp = Visio.ActiveWindow.Selection.Item(1)
Dummy (shp) ' <-- Get Type Mismatch here on compile :(
End Sub

Public Sub Dummy(shp As Visio.Shape)
If (shp.Master Is Nothing) Then
MsgBox ("It's Nothing")
ElseIf (IsEmpty(shp.Master)) Then
MsgBox ("It's Empty")
ElseIf (IsNull(shp.Master)) Then
MsgBox ("It's Null")
Else
MsgBox ("Bingo!")
End If
End Sub
 
K

Kari Yli-Kuha

Lee Bassom said:
Hi all,
I'm hoping someone can help me out with a bit of VBA in Visio.

It looks ok, but I'm getting a type mismatch error :(
(It's just a simple bit of code I'm using to figure out how to do something) [...]
Dummy (shp) ' <-- Get Type Mismatch here on compile :(

should be:
Dummy shp

/C
 
A

al

try this instead...
Public Sub callDummy()
Dim shp As Visio.Shape
If Visio.ActiveWindow.Selection.Count > 0 Then
Set shp = Visio.ActiveWindow.Selection.Item(1)
Dummy shp ' no parens
End If
End Sub

Public Sub Dummy(shp As Visio.Shape)
On Error GoTo dummy_err
If (shp.Master Is Nothing) Then
MsgBox ("It's Nothing")
ElseIf (IsEmpty(shp.Master)) Then
MsgBox ("It's Empty")
ElseIf (IsNull(shp.Master)) Then
MsgBox ("It's Null")
Else
MsgBox ("Bingo!")
End If
dummy_err:
MsgBox "dummy has an error"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top