Set Shape Name in a Shape Data Field Programmatically

Started by david, September 16, 2008, 02:33:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

david

i need to add custom properties to a group by code.
i have a problem writing strings in the properties.

for example the following command writes the string hello in the label of the property.
shape.CellsSRC(iSection, visRowProp + 0, visCustPropsLabel).Formula = """hello"""

but i want to write instead of "hello" the string shape.name (the actual name and not the string "shape.name").

what should i write instead of """hello"""?

thanks in advance
David

Visio Guy

#1
shp.Cells("Prop.Whatever").Formula = "NAME()"

or as you already have started:

shp.CellsSRC(iSection, visRowProp + 0, visCustPropsLabel).Formula = "NAME()"

If you only have one set of quotes, then the string must be a valid ShapeSheet formula. So:

= "Bob"

Will give you an error,

= """Bob"""

Will write "Bob" to the formula, and:

= "Width + 1in."

Will enter that formula.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

david

thanks.  but i didn't really mean shape.name.  it was just an example.  i thought that the answer will be for a general value of type String.
what i want to put there is a string that contains the prperty's name. it is assigned into the variable prop_name.  how can i put there the variable?

Visio Guy

You mean:

  shp.Cells("Prop.Whatever").Formula = Chr ( 34 ) & shp.Name & Chr ( 34 )

?

Or:

  shp.Cells("Prop.Whatever").Formula = Chr ( 34 ) & shp.NameID & Chr ( 34 )

perhaps? I use "Chr ( 34 )" for a double-quote because it prevents the problem of: do I use ", "", """, or """" ?

For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

david


Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 215 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1052KB.
Tokens: post-login.
Cache hits: 13: 0.00154s for 26,588 bytes (show)
Cache misses: 2: (show)
Queries used: 15.

[Show Queries]