我正在创建一个宏,可以自动从Excel电子表格创建visio图表,其中图表代表excel电子表格中连续的连接。我收到了这个错误,我找不到原因,请注意我在vba上经验不足。当我尝试在已经放置的两个对象之间放置连接时,我的问题出现了。再次调用这些对象我试图使用他们唯一的ID但由于某种原因我无法超越第一道障碍。
如果有任何见解可以提供帮助我会很高兴,请原谅凌乱的代码!
While Current_Row < Last_Row
While current_object <= counter
object = "Ellipse." & current_object
Set ShpObj = AppVisio.ActivePage.Shapes(object)
If ShpObj.Text = Worksheets("TempSheet").Cells(Current_Row, COLUMN2).Value Then
While current_get <= counter
object = "Ellipse." & current_get
ShpObj2 = AppVisio.ActivePage.Shapes(object)
If ShpObj2.Text = Worksheets("TempSheet").Cells(Current_Row, COLUMN2).Value Then
ShpObj2.AutoConnect ShpObj, visioAutoconnecDirRight, connector '(setting the color and label)
Set ShpObj2 = Nothing
End If
current_get = current_get + 1
Wend
End If
current_object = current_object + 1
current_get = 1
Set ShpObj = Nothing
Wend
那就是造成问题的块,如果你想看到其他模块,你可以在论坛帖子中找到它http://visguy.com/vgforum/index.php?topic=4633.0
答案 0 :(得分:3)
您似乎忘记了正确设置 ShpObj2
,然后您在条件语句中使用它。
尝试替换
行 ShpObj2 = AppVisio.ActivePage.Shapes(object)
使用:
Set ShpObj2 = AppVisio.ActivePage.Shapes(object)