M
matthew_shomphe
(I posted this in microsoft.public.visio, but got no response. Sorry in
advance if this is cross-posting [I didn't know about this group...])
I've been customizing some of the existing Visio shapes for use at
work. Through the ShapeSheet, I've added the necessary custom
properties and figured out a (ham-fisted, in my opinion) approach to
displaying the custom properties in the shape.
I'd like to find a better way of doing this, preferably through a macro
that will allow me to, for any given shape, add a custom property (with
associated attributes) and display that new text appended to the
existing displayed text.
I can do this by hand, but I'd rather have core shapes that can be
easily extended.
Right now, using the "Divided Process" shape, I've added a custom
property like:
Custom Properties Label Prompt.....
Prop.State "State" "Enter the name...."....
And then in the User-defined Cells I have an entery named
"User.visCustomLabel" with an extensive value:
Prop.PromptName&":
"&CHAR(34)&Prop.PromptText&CHAR(34)&CHAR(10)&Prop.Grammar.Label&":
"&Prop.Grammar&IF(StrSame(Prop.R1,""),Prop.R1,CHAR(10)&"R1")&IF(StrSame(Prop.R2,""),Prop.R2,"
R2")
Then the Text Fields entry contains a row with Fields.Format =
FieldPicture(0) and Fields.Value = User.visCustomLabel
[As an aside, this works, but it seems clunky. Any suggestions as to
make a cleaner implementation of this would be most welcome.]
I've looked in to automating the addition of new fields, but have come
up empty. First, I've Googled for Characters.AddCustomField, but
haven't come up with anything useful. (see:
http://www.google.com/search?source...D,GGLD:2004-49,GGLD:en&q=visio+addcustomfield
[even Microsoft's page is out of date]). I've been able to add a row
to the Custom Properties section, but have not been able to add a row
to the Text Fields section that shows up in the shape.
Here's the VBA code I've done so far:
Public Sub insert_field()
Dim shpObj As Visio.Shape
Dim Chars As Visio.Characters
Dim retVal As Integer
Set shpObj = ActivePage.Shapes(1)
If Not shpObj.CellExists("Prop.NewRow", 0) Then
retVal = shpObj.AddNamedRow(Visio.visSectionProp, "NewRow", 0)
End If
If Not shpObj.RowExists(Visio.visSectionTextField, 2, 0) Then
retVal = shpObj.AddRow(Visio.visSectionTextField, 2, 0)
End If
shpObj.Cells("Prop.NewRow.Prompt").Formula = "=""New_Row_Prompt"""
shpObj.Section(Visio.visSectionTextField).row(2).Cell("Format").Formula
= "=FieldPicture(1)"
shpObj.Section(Visio.visSectionTextField).row(2).Cell("Value").Formula
= "=Prop.NewRow"
This code does NOT work -- there's some EOF error popping up, but it
gives you a flavor of what I'm trying to do.
So, to restate the problem, I'd like pointers to a solution that would
add & display a custom property to a shape.
Thanks in advance!
M@
advance if this is cross-posting [I didn't know about this group...])
I've been customizing some of the existing Visio shapes for use at
work. Through the ShapeSheet, I've added the necessary custom
properties and figured out a (ham-fisted, in my opinion) approach to
displaying the custom properties in the shape.
I'd like to find a better way of doing this, preferably through a macro
that will allow me to, for any given shape, add a custom property (with
associated attributes) and display that new text appended to the
existing displayed text.
I can do this by hand, but I'd rather have core shapes that can be
easily extended.
Right now, using the "Divided Process" shape, I've added a custom
property like:
Custom Properties Label Prompt.....
Prop.State "State" "Enter the name...."....
And then in the User-defined Cells I have an entery named
"User.visCustomLabel" with an extensive value:
Prop.PromptName&":
"&CHAR(34)&Prop.PromptText&CHAR(34)&CHAR(10)&Prop.Grammar.Label&":
"&Prop.Grammar&IF(StrSame(Prop.R1,""),Prop.R1,CHAR(10)&"R1")&IF(StrSame(Prop.R2,""),Prop.R2,"
R2")
Then the Text Fields entry contains a row with Fields.Format =
FieldPicture(0) and Fields.Value = User.visCustomLabel
[As an aside, this works, but it seems clunky. Any suggestions as to
make a cleaner implementation of this would be most welcome.]
I've looked in to automating the addition of new fields, but have come
up empty. First, I've Googled for Characters.AddCustomField, but
haven't come up with anything useful. (see:
http://www.google.com/search?source...D,GGLD:2004-49,GGLD:en&q=visio+addcustomfield
[even Microsoft's page is out of date]). I've been able to add a row
to the Custom Properties section, but have not been able to add a row
to the Text Fields section that shows up in the shape.
Here's the VBA code I've done so far:
Public Sub insert_field()
Dim shpObj As Visio.Shape
Dim Chars As Visio.Characters
Dim retVal As Integer
Set shpObj = ActivePage.Shapes(1)
If Not shpObj.CellExists("Prop.NewRow", 0) Then
retVal = shpObj.AddNamedRow(Visio.visSectionProp, "NewRow", 0)
End If
If Not shpObj.RowExists(Visio.visSectionTextField, 2, 0) Then
retVal = shpObj.AddRow(Visio.visSectionTextField, 2, 0)
End If
shpObj.Cells("Prop.NewRow.Prompt").Formula = "=""New_Row_Prompt"""
shpObj.Section(Visio.visSectionTextField).row(2).Cell("Format").Formula
= "=FieldPicture(1)"
shpObj.Section(Visio.visSectionTextField).row(2).Cell("Value").Formula
= "=Prop.NewRow"
This code does NOT work -- there's some EOF error popping up, but it
gives you a flavor of what I'm trying to do.
So, to restate the problem, I'd like pointers to a solution that would
add & display a custom property to a shape.
Thanks in advance!
M@