If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Macro code to modify connection label (Visio 2003)
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 |
#2
|
|||
|
|||
SOLVED: Macro code to modify connection label (Visio 2003)
Found the problem. The arguments in the CellsSRC function are
different when formatting text color versus background color of a text box. Thanks anyway. On Jul 22, 3:49*pm, Paul wrote: 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 |
#3
|
|||
|
|||
Macro code to modify connection label (Visio 2003)
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 "Paul" wrote: 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 |
Thread Tools | |
Display Modes | |
|
|