Macro code to modify connection label (Visio 2003)

P

Paul

I have grand aspirations to create macros that turn all connections’
text labels transparent, and to turn them visible (white text block
background, text color set to the same as the line color). I started
with something very simple. Or more truthfully, I was forced to
reduce it to the following debugging script.

Public Sub LnLblOn()
Dim shp As Shape
Visio.ActiveWindow.DeselectAll
For Each shp In Visio.ActivePage.Shapes
If shp.OneD Then
'shp.CellsSRC(visSectionObject, visRowText,
visCharacterColor).FormulaU = shp.Cells("LineColor")
shp.CellsSRC(visSectionObject, visRowText,
visCharacterColor).FormulaU = "3"
End If
Next shp
End Sub

I expected this script to set the text color of all connection labels
to “3” (whatever that color is). Hoever, it doesn’t change the color
of any of the labels, regardless of what color they were originally,
and regardless of what color the line is. Instead, it sets all the
text boxes’ right margins to 76.2mm. Why would this be?

Aside from the field that is being changed, there is not much
difference between the above code and the following (properly working)
code for clearing the text block background, and setting it to white:

Public Sub LnLblBkgndClr()
Dim shp As Shape
Visio.ActiveWindow.DeselectAll
For Each shp In Visio.ActivePage.Shapes
If shp.OneD Then
shp.CellsSRC(visSectionObject, visRowText,
visTxtBlkBkgnd).FormulaU = "0"
End If
Next shp
End Sub

Public Sub LnLblBkgndWht()
Dim shp As Shape
Visio.ActiveWindow.DeselectAll
For Each shp In Visio.ActivePage.Shapes
If shp.OneD Then
shp.CellsSRC(visSectionObject, visRowText,
visTxtBlkBkgnd).FormulaU = "2"
End If
Next shp
End Sub
 
P

Paul

Found the problem. The arguments in the CellsSRC function are
different when formatting text color versus background color of a text
box. Thanks anyway.
 
W

WapperDude

Change your text color line --
from: shp.CellsSRC(visSectionObject, visRowText,
visCharacterColor).FormulaU = "3"

to: shp.CellsSRC(visSectionCharacter, 0, visCharacterColor).FormulaU =
"RGB(255,0,0)"

You may use the color index method, e.g., "3", which is green, or as shown,
the RGB method and make any color you want.

Enjoy!
Wapperdude
 

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