Locked (Read-only) Custom Properties / Shape Data Fields

Started by Lars-Erik, May 21, 2008, 11:16:35 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Lars-Erik

Ok here goes, I want users to insert data for each shape.
There are however some data fields I do want to show, but not allow users to change.
The reason for this is that I'm linking Visio with a PDM tool, the tool reads the drawing and then assigns a number, description and class to each shape according to its data in Visio (that the user does enter).
So the shape data holding the tool's data need to show up in Visio but cant be edited, one way to do this is using Guard("Assigned number"). Users can still edit the fields, but it wont be changed as its guarded. What I'd like to know is this: Is there a nicer way of doing this, perhaps grey out the field?

- Lars

Visio Guy

Very often requested feature (in fact, how about putting this in the Visio 14 Feature Requests?

Crappy work-arounds I have done in the past:


  • Place the information (say: Prop = Val) in a disabled right-mouse menu action
  • GUARD the Shape Data field (like you said)
  • Put the value in the name of the Shape Data field (ie: the Label cell)
  • Show the info as text on the shape somewhere
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Lars-Erik

Mmmm, ok. Suppose the best option is to work with Guard (as i want to keep the properties out of the drawing and only show up in the property listings.)

Guess best case scenario, make a checkbox (a boolean in the shapesheet) that makes it "disabled"
Ill post it in requested features. Thx for the response Chris.

- Lars

vojo

custom property that is a fixed list where the format has the actual data.   You can show, but user cant change
you may want 1 custom property to allow user to set the value....another to display elsewhere where its format and data come from the first custom property

Lars-Erik

Mmm, that and using Guard() are probably the two best workarounds. But still... there workarounds. Ive posted this as a requested feature.

Visio Guy

Thanks vojo,

I knew there was another technique that I was forgetting!

So for newcomers to this thread, here's another way to create a read-only Shape Data (Custom Property) field: make it a fixed list with one item!

For example, "Prop.Info" would be set up like this:

Prop.Info.Label = "Info (Read Only)"
Prop.Info.Type = 1
Prop.Info.Format = "The Only Value"
Prop.Info.Value = "The Only Value"

Note: Normally, the Format cell holds a list, such as "Item 1;Item 2;Item3", but by putting only one item in the list, the user can't change it, just read it.

Also, I put a "(Read Only)" reminder in the .Label cell. Not a requirement, but perhaps a UI enhancement to help your users.



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

perry59

Sorry for reviving such an old post but I have a need.
I too wish to guard shape data, but I see NO cell in the protection area of the shapesheet for custom properties.
I see a cell for disallowing adding custom props, but no cell for disallowing editing of custom props
How do you do this?
thanks
what, me worry?

vojo

if you really want to lock a prop field, then 2 options

Option 1:  If never changed then  prop.mycoolfield.value = guard(<value>)

Option 2:  If you want some change values but lock when done then more complicated.
               need to can use the setatref functions (not trivial at all)  or
               prop.mycoolfieldpubic = guard(prop.mycoolfieldprivate)
               prop.mycoolfieldprivate = <value>     
               logic around prop.mycoofieldprivate.hidden to control when visible and when hidden.  if hidden, user cant change

for option 2, you should experiment on a dummy shape  before you implement in your shape.
get the logic right and test all the use cases

perry59

had a brain lapse there, remembered how to do that :o

Thanks!
what, me worry?

Visisthebest

Visio Guy thank you very much for this great tip!

Quote from: Visio Guy on May 26, 2008, 08:47:55 PM
Thanks vojo,

I knew there was another technique that I was forgetting!

So for newcomers to this thread, here's another way to create a read-only Shape Data (Custom Property) field: make it a fixed list with one item!

For example, "Prop.Info" would be set up like this:

Prop.Info.Label = "Info (Read Only)"
Prop.Info.Type = 1
Prop.Info.Format = "The Only Value"
Prop.Info.Value = "The Only Value"

Note: Normally, the Format cell holds a list, such as "Item 1;Item 2;Item3", but by putting only one item in the list, the user can't change it, just read it.

Also, I put a "(Read Only)" reminder in the .Label cell. Not a requirement, but perhaps a UI enhancement to help your users.
Visio 2021 Professional

Phojes

Hey guys, here comes another late reply / addition:
Is there any way to protect the "name" cell for custom properties from changes? So it is only editable in the shapesheet and not via "define shape-data"?
For all the other cells I'm fine with usind the guard()-function but that doesn't work there, of course.

Surrogate

Quote from: Phojes on August 05, 2021, 05:48:47 AM
Is there any way to protect the "name" cell for custom properties from changes?
There is not "name" of cell, it is "label" !

You can create user-defined cell with formula like this
QuoteIF(STRSAME(Prop.Row_1.Label,"OLOLO"),SETF(GetRef(Prop.Row_1.Label),"""ololo"""),SETF(GetRef(Prop.Row_1.Label),"""ololo"""))

Surrogate

Quote from: Surrogate on August 05, 2021, 06:17:58 AMIs there any way to protect the "name" cell for custom properties from changes?
If the user does not enable developer mode, he only sees the label in the "Define shape data" window.
But when developer mode is enabled, you will see the names of the rows that you can't prohibit to change the row name.  :(

Visisthebest

Is it possible in VBA to check if Developer Mode is enabled, and to enable/disable it with VBA?
Visio 2021 Professional

Surrogate

#14
Quote from: Visisthebest on August 05, 2021, 04:26:27 PM
Is it possible in VBA to check if Developer Mode is enabled, and to enable/disable it with VBA?
you can check it
Application.Settings.DeveloperMode and turn out
If Application.Settings.DeveloperMode Then Application.Settings.DeveloperMode = Not Application.Settings.DeveloperMode