Problem accessing Custom Properties via C# Add-in

N

Neil

I am developing a module in C# to link to Visio. I am having problems getting
values from the ShapeSheet. I am trying to store some custom data in the
Custom Properties section of the shape sheet. I can add and view this through
both mechanisms that I am aware of in Visio (shape sheet window and the
custom properties dialog). However, I am unable to get the values via C#.

I am storing strings in the Custom Properties.

Given a specified Shape, I am trying the following:

Cell cell = shape.get_Cells("Prop.Model.Value");
string s = cell.get_ResultStr(0);

From the docs, the value 0 appears to be the correct way to get a string
value from a cell. However, this always returns me 0.0000. I have tried the
other values in the range from 1 to 255 and I always get a variant of 0.0.

I have defined this property in the Master for the Shape.

Can anyone help me access string values?

Neil
 
N

Neil

I should note that I am on Windows XP running Visio 2003 Professional SP2.
Writing C# add-in using Visual Studio .NET 2003.
 
C

Chris Roth [MVP]

Also, you can have a look at the Visio.VisUnitCodes enumeration. These items
are used in the ResultStr argument. I use "visNoCast" quite often myself.

--
Hope this helps,

Chris Roth
Visio MVP

More Visio shapes, articles, development info and pure diagramming fun at:
www.visguy.com
 
N

Neil

Thanks Chris and David for your suggestions,

I have now made some progress. I can now read values from the Custom
Properties section that I have added to an instance of one of the electrical
symbols supplied with Visio Pro. However, if I create my own master shape and
add it to a sheet I do not seem to be able to read the custom properties :-(

If I add a User section to my symbol I am told that it is not present (using
get_SectionExists(((short)VisSectionIndices.visSectionUser), ((short)0) ) and
checking that it is not 0).

So, I will investigate further and might have some follow-up questions.

Regards,

Neil
 
N

Neil

In follow-up, it appears that my problem with the code is to do with the way
that I constructed my custom shapes. I do not fully understand the issue, but
I went back and redefined the shape, adding extra geometry via the shape
sheet rather than drawing multiple elements and then grouping.

In this way, I can now access and set the values using the get_ResultStr()
method.

Neil
 

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