did you define a
dim visCell as visio.cell
?
I usually get one of thos #NAME errors when I try to access a cell that doesn't exist (i.e. visio couldn't find the object with that name). That's why I test before I try to do anything with something I had the responsibility of building. There's also a
routine (StringToFormulaForString) in the visio sdk that can be used to wrap/format strings before putting them into cells. You can also try something
like this
al
'
'
'
Public
Sub
SetCustomPropertyFormula( _
ByVal
customPropertyShape As
Visio.Shape,
_
ByVal
rowNameU As
String,
_
ByVal
universalSyntaxFormula As
String)
Const
CUST_PROP_PREFIX As
String
= "Prop."
Dim
customPropertyCell As
Microsoft.Office.Interop.Visio.Cell
Dim
visioApplication As
Microsoft.Office.Interop.Visio.Application
visioApplication =
CType(customPropertyShape.Application,
_
Microsoft.Office.Interop.Visio.
Application)
Try
' Verify that all incoming string parameters are
not of zero
' length, except for the ones that have default
values as ""
' and the output parameters.
If
(rowNameU.Length() = 0) Then
Throw
New
System.ArgumentNullException("rowNameU",
_
"Zero length string input.")
End
If
If
(universalSyntaxFormula.Length() = 0) Then
Throw
New
System.ArgumentNullException(
_
"universalSyntaxFormula",
"Zero length string input.")
End
If
' See if the shape has a custom property Value
cell with the
' universal row name. If no cell exists, display
an error
' message and exit this procedure.
If
Not
CBool(customPropertyShape.CellExistsU(
_
CUST_PROP_PREFIX & rowNameU,
CShort(False)))
Then
If
visioApplication.AlertResponse = 0 Then
MsgBox(
"This shape "
_
&
"does not have a custom property "
& vbCrLf & _
"with the universal name '"
& vbCrLf & rowNameU & _
"'.")
Return
End
If
End
If
' Get the Cell object. Note the addition of "Prop."
to the name
' given to the cell.
customPropertyCell = customPropertyShape.CellsU( _
CUST_PROP_PREFIX & rowNameU)
' change when the width of the shape changes.
customPropertyCell.FormulaU = universalSyntaxFormula
Catch
Err As
Exception
System.Diagnostics.
Debug.WriteLine(Err.Message)
End
Try
End
Sub