How can I obtain a shapes protection properties in C#?

Started by eggmatters, October 24, 2008, 12:04:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

eggmatters

Hi, I am trying to edit a visio programatically in C#. Some shapes are protected, others aren't. Luckily, I'm only interested in the unprotected shapes. I've tried to navigate through all of the various COM properties for a shape but I don't see anything that might describe what kind of protection a shape may have. Does anybody know how to discern this?

Paul Herber

You need the shape's cellsSRC property with parameters visSectionObject, visRowLock plus one of the protection indicators - visLockWidth, visLockHeight, visLockMoveX etc

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Visio Guy

In general, you can get most of the information about a shape via the ShapeSheet cells. You get to these via:

Cells(cellName)
CellsU(cellName)
CellsSRC( section, row, column )

In C# some of these have a "get_" prepended.

Once you've got a ShapeSheet cell, you can ask it for a Formula, or a ResultIU, or a Result( unitCode )

ResultIU returns a numerical value. If the number has a length-meaning, then the number in Visio's internal units, which are inches.

For Protection, you're just interested in 1 (=protected) or 0 (=not protected), so ResultIU is the easiest way to check the value, and the results don't have anything to do with length, so you are just looking for 1 or 0.

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

eggmatters

Thanks! I will need to look into more specifics of the cells properties. Can you recommend a good resource that describes these?

Visio Guy

Visio has a developer's reference help file built in, but it's hard to use.

The Visio 2007 SDK has a nice help file

If you like to read, I can recommend two Visio development books that are both top notch:

1. The Visio 2003 Developer's Survival Pack is still relevant for Visio 2007 development.
2. David Parker's Visualizing Information with Microsoft Visio 2007 offers a great blend of advice for both über-power users and developers.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Browser ID: smf (is_webkit)
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: 226 (show)
Files included: 34 - 1321KB. (show)
Memory used: 1137KB.
Tokens: post-login.
Cache hits: 13: 0.00176s for 26,584 bytes (show)
Cache misses: 2: (show)
Queries used: 17.

[Show Queries]