Runtime error assigning formula in macro

S

Simon P

I have a VBA macro in Visio 2003 Professional which gives a runtime error
when assigning the EventDblClick cell formula for the selected shape. I've
included the relevant code below. Interestingly if the shape sheet for the
current selection is opened and the CALLTHIS string is manually entered into
the EventDblClick formula, tha value is accepted without an error and the
double click behaviour subsequently works as I had hoped - ie calling the
showEntryMapShapeProperties method.

Does anyone know why the macro should fail on this line. Are there any
security settings which might prevent the assignment of cell formulas in
macro whilst allowing them to be done manually via the shape sheet.

Many thanks in advance

---------------------------

Public Sub makeEntryMapShape()
Dim sh As Shape
Dim conn As Shape
Dim x As Double, y As Double
For Each sh In ActiveWindow.Selection
With sh
.Cells("EventDblClick").Formula =
"=CALLTHIS(""ThisDocument.showEntryMapShapeProperties"",""entrymap"")"
End With
Next sh
End Sub


Private Sub showEntryMapShapeProperties(sh As Shape)
....
 
J

junethesecond

No problem found in my system.
It should work, if security settings
are as usually, i.e.,
permit macro run, permit automation
events.
 
S

Simon P

Yes - I have both those settings checked, thanks. I've finally got around
the problem by trial and error. In desperation I changed the line to assign
a meaningless value into the cell formula, just a single character - and
then the macro worked. So I gradually built the right hand side value back
up to what it was before and discovered that it was the second parameter,
ie ""entrymap"" which was causing it to fail. I am still baffled as to why?
Anyway this parameter is optional so I have simply removed it and it works
fine now.

Thanks for your input.
 
J

junethesecond

Please, make sure that
project named "entrymap"
exist in the project explorer
of VBA edtor.
 
V

visdev1

I haven’t programmed with visio long, and I am not that familiar with the
CALLTHIS command but could your problem be that you are sending a string
""entrymap"" to a sub that expects a visio shape:(sh as Shape)? Try changing
the sub to accept a string.

showEntryMapShapeProperties(sh As Shape)
 

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