"Action" Problem(s)

J

Joe Cletcher

I'm just trying to add a right-click option for a shape
that passes the "ShapeKey" property of the shape that
was "right-clicked" to and then executes a macro I have
written. It's not working. Anyone see what I'm doing
wrong?

The macro and the "Action" lines are shown below. Only
the 1st action line (DOCMD(1312)) works. The macro just
shows a form with the faked "ShapeKey" and a single
command button.


Public Sub ShowCustomData()
Dim aForm As New frmMsnAsrncIssues
Dim ShapeKey As Long

ShapeKey = 35
aForm.rtbShapeID.Text = "Shape ID: " & CStr(ShapeKey)
aForm.Show
End Sub


Private Sub cmdOK_Click()
End
End Sub


Action 1:
Action: DOCMD(1312)
Menu: "Properties..."
Checked: 0
Disabled: 0

Action 2:
Action: RUNADDON("ShowCustomData")
Menu: "Show Mission Assurance Issues"
Checked: 0
Disabled: 0
 
B

Bill K. [MSFT]

Change the action to: RUNADDON("ThisDocument.ShowCommandData")

A second way to handle it is with the CallThis() shapesheet function.
It will pass a reference to the shape, which is handy for looking up
properties from the shape.

action: CALLTHIS("ThisDocument.ShowCommandData")

vba macro:
Public Sub ShowCommandData(visShape as Visio.Shape)
Dim ShapeKey as String
ShapeKey = visShape.Cells("Prop.MyKey").ResultStr(0)
End Sub

Hope this helps,
 
J

Joe Cletcher

Thanks! Would have gotten back to you sooner, but my
group's offices were moved to new digs and computers were
down until today about noon.

Tried "CallThis" and
"RUNADDON" with the following argument
("ThisDocument.ShowCustomData"). Neither syntax executed
the macro "ShowCustomData". When I entered the command
via the EDIT/ACTION menu choice VISIO entered
RUNADDON("JIMO.Module1.ShowCustomData") as the action
item--that did not work either.

Still cannot get my user-defined macro to execute as
an "action" method of a VISIO shape.

If I can get that to work, then I'll worry about
including the VISIO.SHAPE as an argument to my
macro "ShowCustomData".

I've used a break point at the first executable statement
in the macro and it never reaches the break point when
attempting to execute the macro from the action right-
click menu choice--macro works fine when requested from
the TOOLS/MACROS/JIMO/Module1/ShowCommandData menu item.

Still at a loss--any other thoughts?
 
P

Peter Suter

Hi Joe

Make shure, that you have written your Macro in the "ThisDocument"-module!

Visio-HELP says:

Example 1
RUNADDON("Calendar.exe")

Launches an add-on called Calendar.exe.

Example 2
RUNADDON("Array Shapes")

Launches the (VSL-implemented) add-on whose name is Array Shapes.

Example 3
RUNADDON("ThisDocument.ReportStatistics")

Calls the ReportStatistics macro in the ThisDocument module in the document
project containing this function call.

Note To invoke a macro in the ThisDocument module, you must preface the
string with "ThisDocument" as shown.

Example 4
RUNADDON("ModuleName.ReportStatistics")

Calls the ReportStatistics macro in ModuleName in the document project that
contains this function call.


Try it again!

--
Regards

Peter Suter
Ing.
CH 3255 Rapperswil BE
 
J

Joe Cletcher

Thanks! Enough of a clue to get the call to the macro to
work. I originally had the module and the form under a
user-defined stencil. When I created the module and the
form in the flow diagram, everything worked.

If you use the "CALLTHIS" function instead of
the "RUNADDON" function in the action statement of the
shapesheet, the VISIO shape object is provided as an
argument value for the macro I defined. Then I can use
the VISIO.Shape.ID property to get a unique identifier
for the shape--hope it is the same as the "shapekey" when
linking to a database. I'll have to check out
the "shapekey" and VISIO.Shape.ID relation.

Again, THANKS!
 

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