0
votes

I'm trying to figure out how to go through a 50 page Visio Doc and take out the text within all of a particular shape. They are all "subprocess" shapes. I'm not sure what the best way to go about it is, and I attempted to just go through each shape on every page and check if it's name matches to "Subprocess." + iterated number. It would basically iterate through like 200 shape names for each shape: crazy and won't work. Not sure how to do this as they all have unique names, but I do know that each name starts with "Subprocess."

Code so far:

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

Thanks!

1

1 Answers

0
votes

You can just use the Like keyword to test whether a string matches the 'Subprocess' pattern. See below.

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