Итерация по динамическим соединителям для изменения цвета на основе текста - PullRequest
0 голосов
/ 29 октября 2019

Мне нужно перебрать все динамические соединители в документе 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

Но текст фигуры не является свойством - даже если в соединителе явно есть текст, и свойства этого текста, такие как шрифт, действительно появляются.

Любая помощь будет отличной - ура

1 Ответ

0 голосов
/ 29 октября 2019

Может быть:

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
...