我需要遍历visio文档上的所有动态连接器,并根据动态连接器文本标签更改连接器线的颜色-该代码基于先前的问题来更改动态连接器的线宽。
我找不到定义文本标签的框
Sub Macro1()
Dim shp As Shape, mst As Master
' iterate all shapes per page
For Each shp In ActivePage.Shapes
' declare parent master for current shape
Set mst = shp.Master
' Process only shapes that have parent master-shape
If Not (mst Is Nothing) Then
' change only shapes, which master-shape is dynamic connector
If mst.Name = "Dynamic connector" Then
' Now i dont know how to proceed - forgive me i am new to coding - i know the syntax is wrong, im just trying to give somthing to go off
If shp.Text = "A" Then shp.Cells("LineColour").Formula = RGB(255,255,0))
Else If shp.Text = "G" Then shp.Cells("LineColour").Formula = RGB(0,255,0))
Else If shp.Text = "R" Then shp.Cells("LineColour").Formula = RGB(255,0,0))
End If
End
但是形状文本似乎不是属性-即使连接器明显具有文本,并且该文本的属性(如字体)也会出现。
任何帮助都会很棒-加油
答案 0 :(得分:0)
也许:
ActivePage.Shapes(shp.Name).TextFrame.Characters.Text = "Hello World!"
'or
shp.TextFrame.Characters.Text = "Hello World!"
' This macro works in Excel
Sub Macro1()
Dim shp As Shape
Me.Shapes.AddShape msoShapeLeftArrow, 200, 200, 10, 10
For Each shp In Me.Shapes
shp.TextFrame.Characters.Text = "A"
Debug.Print shp.name, shp.TextFrame.Characters.Text
Next
End Sub