Getting Custom Property Data

J

jpabich

I have stencils that I have created custom properties for. I would
like to retrieve this data and display it so I know I am accessing the
correct property. My code is as follows:

Visio.Cell celobj2;
celobj2 = visShape.get_Cells("Prop.Test");
MessageBox.Show(Convert.ToString(celobj2.FormulaU));

I get an unexpected end of file error when I try this. What is
incorrect about this code? How do I get the property value?
 
J

jmlight0

I recently had the same problem and was able to get around it by calling your
custom property by the name Visio gave it rather than the name you gave it.
Go to the style sheet for the shape and find the row in the "custom
properties" section that corresponds to your "test" property (should be
something like "Row_3". In your second line of code below, use the "Row_3"
type name instead of the "test" name. For example:

celobj2 = visShape.get_Cells("Prop.Row_3");

There may be a better way around the problem, but this seems to work.
 
J

jpabich

That worked. I am still interested in finding out how to use my own
names for properties. That will eliminate confusion for the number of
properties I will be using.

Thanks for your help.
 
M

Mark Nelson [MS]

It sounds like you are running into differences between Local and Universal
names of cells in the Shapesheet. Most objects in Visio have two names.
The Local name is shown to the user. They are often shown in the language
of the user (e.g. French, German, English). Universal names are not shown
to the user and never change unless you programmatically modify them.

When you use the Cells method to retrieve a cell, you are asking for the
cell by its local name. When you use the CellsU method to retrieve a cell,
you are asking for the cell by its universal name. The tricky part here is
that these two names may start out the same, but they can become different
over time. The best practice is to ALWAYS use universal names and syntax in
your code. That means calling ItemU, CellsU, FormulaU, ResultsU etc. If
you aren't using methods with a U in them, you better make sure there isn't
an alternative version with a U. Universal names were added after local
names, and so the non-U methods are available for backwards compatibility.
You should avoid them for new code.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

jpabich

How do I set the universal name? I am a bit confused between the two.
I created a new custom property with a label of Test. There was no
name option to fill in. Where do I look in Visio to view the actual
names that are accessed?
 
P

Paul Herber

How do I set the universal name? I am a bit confused between the two.
I created a new custom property with a label of Test. There was no
name option to fill in. Where do I look in Visio to view the actual
names that are accessed?

Install my utilities

http://www.visio-utilities.sandrila.co.uk/

there is a report 'Page Custom Properties Report' which will display
the local and universal names and also if there is a difference ask if
you want to correct the name.
 
J

jpabich

I do not have a report Menu. I have File, Edit, View, Insert, Format,
Tools, Shape, Window and Help.
 
P

Paul Herber

Have you installed the utilities mentioned in my first reply and has
it added the new menu?


I do not have a report Menu. I have File, Edit, View, Insert, Format,
Tools, Shape, Window and Help.
 
J

jpabich

I tried, but it upset my virus scanning software, so I chose not to
continue with the install. I will figure some other way around it.
 
P

Paul Herber

I tried, but it upset my virus scanning software, so I chose not to
continue with the install. I will figure some other way around it.

Eh? Please tell me more! Which virus scanner? What did it say?
 
H

Heidi Munson [MSFT]

Custom properties have Labels which appear in the custom property dialog as
well row names (local and universal) for the row in the shape sheet. Labels
can contains spaces and other characters not allowed in row names. You need
to use the row name with the "Prop." prefix to build cell names. To see
and edit row name in the define custom property dialog you need to be
running in developer mode. You can also see and edit the row name in the
ShapeSheet Window. If you are running Visio 2002 or earlier the row name in
the ShapeSheet window and define dialog is the local name. In Visio 2003
this was changed to show the universal name.

See this related thread for more details:
http://www.mcse.ms/archive197-2004-8-947683.html

-Heidi
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights
 
A

asoofi

Lately I've been having trouble trying to set the Custom Property Data
with the C/C++ wrapper classes for Visio.

I've looked into other threads and other groups, and have seen previous
examples, but in almost all instances, my hr comes back invalid, even
by the simplest of operations.
Could anybody post the short code necessary to set a custom property
cell?

Thank you.
~Amir.
 

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