Passing Custom Properties from a Shape to VBA Form

C

Colin Sheppard

Hello,

I would like to create a form in VBA where I can list and modify
Custom Properties from a Shape that contains them. What I
particularly need help with is:

1 - How to reference the macro from the 'Double Click' setting for a
macro of your choice in its behaviour?

2- How to pass all the shape's properties, including the custom
properties from the selected Shape File (by the behaviour of 'Double
Click' into the form where they can be shown?

3 - (optional) How could I spell check each Custom Property's text
value?

Thank you for your kind clarification and assistance.

Regards,

Colin Sheppard.
 
H

Hadriel

If I understand you right, then in general terms, you'll want to call a
procedure you create using the CallThis function inside the EventDblClick
cell of the shape's shapesheet. For example, the formula for the cell would
be:
CALLTHIS("ThisDocument.MySub",)
That's assuming you defined a procedure in the ThisDocument module of your
VBA code as:
public sub MySub(byref shpObj as visio.shape)
'do stuff in here with shpObj
end sub
For your second question, it's not easy, but you would have get each cell's
formula or result for the shpObj passed above. So for example:
public sub MySub(byref shpObj as visio.shape)
dim strProp as string
strProp = shpObj.cells("User.Prop.Speed").Formula
end sub
That would get the formula of the Value cell of the Custom Properties row
which I named "Prop.Speed" (really I named it "Speed" but visio adds the
"Prop." part) of the shape that the user double-clicked on. There are about
a dozen ways to reference cells (See Help/SDK), and using getformulas or
getresults is a faster method if you have a bunch of property cells to get
(but it is more complicated).
To get it into a form is trickier, but one example would be:
public sub MySub(byref shpObj as visio.shape)
frmMyForm.Show
frmMyForm.txtSpeed.text = shpObj.cells("User.Prop.Speed").Formula
end sub
That's assuming you created a form called frmMyForm with a textbox named
txtSpeed on it that you can set properties for.
-hadriel
 

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