Type Mismatch in VBA macro

N

Nevo

I'm having a heck of a time trying to figure this out. When I run the
DumpAllDocuments macro, I get a type mismatch error calling DumpDocument.

I have no idea why this is happening. Can anyone help?

Code:
Public Sub DumpAllDocuments()
IndentLevel = 0
Dim vsDoc As Visio.Document
For Each vsDoc In Visio.Documents
DumpDocument (vsDoc)
Next
End Sub

Private Sub DumpDocument(iDoc As Visio.Document)
...
End Sub
 
A

AlEdlund

this works,
(parens removed from the subroutine call)
al


Public Sub DumpAllDocuments()
IndentLevel = 0
Dim vsDoc As Visio.Document
Dim vsDocs As Visio.Documents
Set vsDocs = Application.Documents
For Each vsDoc In vsDocs
DumpDocument vsDoc
Next
End Sub

Private Sub DumpDocument(iDoc As Visio.Document)
' something happens
End Sub
 
C

Chris Roth [Visio MVP]

VBA has this "dual mode" way of calling functions and subs.

You can do it without parentheses:

DumpDocument vsDoc

Or with parentheses, using "Call" at the beginning:

Call DumpDocument(vsDoc)

I always use the "Call" method, because I like to see the parentheses.
The space is visually inconsistent and confusing for me.

Also, if I import to VB.NET, it is easy to get rid of the Calls by doing
a replace with "". (Although I think VB.NET supports the Call statement)

--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People

Articles: http://www.visguy.com
Shapes: http://www.visguy.com/shapes
Dev: http://www.visguy.com/category/development/
Forum: http://www.viguy.com/vgforum
 

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