Visio VBA 脚本

Visio VBA Script

我正在尝试弄清楚如何浏览 50 页的 Visio Doc 并取出所有特定形状内的文本。都是"subprocess"的形状。我不确定最好的方法是什么,我试图浏览每一页上的每个形状并检查它的名称是否与 "Subprocess." + 迭代数字匹配。它基本上会为每个形状迭代 200 个形状名称:疯狂而且行不通。不知道该怎么做,因为它们都有唯一的名称,但我知道每个名称都以 "Subprocess."

开头

到目前为止的代码:

Public Sub FindOffPageShapes()
Dim shp As Visio.Shape
Dim pagShape As Visio.Shape
Dim myInt As Integer
    Set pagShape = Visio.ActivePage.PageSheet
    For Each shp In Visio.ActivePage.Shapes
        While shp.Name <> "Subprocess." & CStr(myInt) Do
            Do myInt = myInt + 1
        If shp.TextFrame.Characters.Name = "Subprocess." & CStr(myInt) Then
            shp.Text = ""
        End If
Next shp
End Sub

谢谢!

您可以只使用 Like 关键字来测试字符串是否与 'Subprocess' 模式匹配。见下文。

Option Compare Text
Public Sub FindOffPageShapes()
Dim shp As Visio.Shape
Dim pagShape As Visio.Shape
Dim myInt As Integer
    Set pagShape = Visio.ActivePage.PageSheet
    For Each shp In Visio.ActivePage.Shapes
        If shp.Name like "Subprocess*" Then
            shp.Text = ""
        End If
    Next shp
End Sub