CellU and CellUExists not working for custom properties

S

Scott

Using Visio 2003, I'm trying to determine if a shape object contains a
specific property, like this:

If shpObj.CellExistsU("Prop.ECAT", Visio.visExistsAnywhere) Then
Set cellObj = shpObj.CellsU("Prop.ECAT")
MsgBox "ECAT value is " & cellObj.ResultStr(Visio.visNone)
End If

The message box never appears. However, if I loop through all properties of
the shape like this, I *do* in fact see an ECAT property. 'cell' below is
an Excel cell reference:

For k = 0 To shpObj.RowCount(Visio.visSectionProp) - 1
' Get the name of the custom property
Set cellObj = shpObj.CellsSRC(Visio.visSectionProp, k, 2)
cell.Offset(0, over + 1).Value = "Property '" &
cellObj.ResultStr(Visio.visNone) & "'"

' Get the value of the custom property
Set cellObj = shpObj.CellsSRC(Visio.visSectionProp, k, 0)
cell.Offset(0, over + 2).Value =
cellObj.ResultStr(Visio.visNone)

Set cellObj = Nothing

Set cell = cell.Offset(1, 0)
Next k
 
M

Mark Nelson [MS]

Your code worked fine when I tried it. Two things come to mind. First, the
error is in a line of code that you didn't show. Second, the custom
property has a different universal name than local name. You might try
using CellExists instead of CellExistsU to confirm this.

Here is the code that worked for me:
Public Sub ListProps()
Dim shpObj As Shape
Dim cellObj As Cell

Set shpObj = ActivePage.Shapes(1) 'Code to get my test shape
If shpObj.CellExistsU("Prop.ECAT", Visio.visExistsAnywhere) Then
Set cellObj = shpObj.CellsU("Prop.ECAT")
MsgBox "ECAT value is " & cellObj.ResultStr(Visio.visNone)
End If
End Sub
 
H

Heidi Munson [MSFT]

I think you may be confusing the value of the custom property label cell
with the name of the cell.

In standard custom property dialog you see the label. The custom property
row has name separate from that label and the each cell in the custom
property row has a name that is derived from the row name. To see the row
name in the custom property define dialog, you need to be running in
developer mode. Go to tools > options. Choose the advanced tab and select
developer mode. Another way to see the your name for your existing custom
properties is to go to the ShapeSheet window. Select your shape and go to
the Window menu and select show ShapeSheet . RMA on the shape sheet window
and make sure the custom property are being displayed. Then scroll to
them. The name of the custom property row appears in the gray cell on the
far left. Here's the docs on the custom property row,
http://msdn.microsoft.com/library/en-us/devref/HTML2/DSS_Rows_(A-Z)_1344.asp

In your code these lines are getting the label cell and its cell value.

Set cellObj = shpObj.CellsSRC(Visio.visSectionProp, k, 2)
cell.Offset(0, over + 1).Value = "Property '" &
cellObj.ResultStr(Visio.visNone) & "'"

To get the name of the label cell do

cellObj.Name

Pass the cell Name to CellsU and CellsExistU to get the label cell or
determine if the label cell exists.

There are samples for adding and getting custom properties in code librarian
Visio 2003 SDK.
http://www.microsoft.com/downloads/details.aspx?familyid=557120bd-b0bb-46e7-936a-b8539898d44d

-Heidi
Microsoft Corporation

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

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