简体   繁体   English

VBA对于Visio中形状的粘合形状的每个循环

[英]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. 我正在尝试遍历形状粘胶形状,并进行一次迭代,然后中断,在第二次迭代期间在Me.Application.ActivePage.Shapes(i).GluedShapes(visGluedShapesAll2D,“”)上给出“无效的参数错误”。 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. 在这段代码中,我遍历所有形状以寻找特定类型,然后遍历GluedShapes数组,并检查其ID是否等于每个数组元素返回的ID。

The code is as follows: 代码如下:

 For i = 1 To Me.Application.ActivePage.Shapes.Count
        If InStr(Me.Application.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. 其中s是当前形状,上面给出的是我的第一个形状的ID,因为当前形状只能连接到一个父形状,所以将当前形状粘贴到该形状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM