开发者

VBA For each loop for gluedshapes of a shape in Visio

i am trying to loop through a shapes gluedshapes and it iterates once then breaks giving an "invalid parameter error" on Me.Application.ActivePage.Shapes(i).GluedShapes(visGluedShapesAll2D, "") during the second iteration. Surely if it runs correctly on the first iteration it should run correctly on the second and third etc...

In this code I am running through all shapes looking for a specific type, I then iterate through the GluedShapes Array and check if it's id is equal to the id returned per array element.

The code is as follows:

 For i = 1 To Me.Application.ActivePage.Shapes.Count
        If InStr(Me.Appl开发者_JS百科ication.ActivePage.Shapes(i).Name, "Flow Connector") > 0 Then
            For Each j In Me.Application.ActivePage.Shapes(i).GluedShapes(visGluedShapesAll2D, "")
                If s.ID = j Then
                End If
            Next j
        End If
    Next i

Thanks, any help will be appreciated.


There is no need to loop through all shapes I could just use

 Dim s As Shape
 Dim id As Variant

 Set s = Application.ActiveWindow.Page.Shapes.ItemFromID(Selection.PrimaryItem.id)

 id = s.GluedShapes(visGluedShapesAll1D, "")(0)

Where s is the Current shape and the above gives me id of the first shape my current shape is glued to as this shape can only be connected to one parent shape.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜