1
我正在嘗試做最簡單的事情 - 在Visio中使用宏連接兩個2D圖形。 我已經下降了兩個形狀,添加到他們的連接點與「進」和「出」。 現在,當我試圖用鼠標連接它們時,它一切正常。 後來我已經錄製宏:在visio中連接兩個2D圖形
Sub Macro1()
'Enable diagram services
Dim DiagramServices As Integer
DiagramServices = ActiveDocument.DiagramServicesEnabled
ActiveDocument.DiagramServicesEnabled = visServiceVersion140
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("1")
ActiveWindow.DeselectAll
ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(1), visSelect
Application.ActiveWindow.Selection.Move -1.161417, 0.669291
Dim vsoCell1 As Visio.Cell
Dim vsoCell2 As Visio.Cell
Set vsoCell1 = Application.ActiveWindow.Page.Shapes.ItemFromID(1).CellsU("PinX")
Set vsoCell2 = Application.ActiveWindow.Page.Shapes.ItemFromID(15).CellsSRC(7, 0, 0)
vsoCell1.GlueTo vsoCell2
Dim vsoCell3 As Cell
Dim vsoCell4 As Cell
Set vsoCell3 = Application.ActiveWindow.Page.Shapes.ItemFromID(1).CellsSRC(visSectionConnectionPts, 0, 0)
Set vsoCell4 = Application.ActiveWindow.Page.Shapes.ItemFromID(15).CellsSRC(visSectionConnectionPts, 0, 0)
vsoCell3.GlueTo vsoCell4
Application.EndUndoScope UndoScopeID1, True
'Restore diagram services
ActiveDocument.DiagramServicesEnabled = DiagramServices
End Sub
而且它不工作...如果我unglue那些形狀和運行錄製的宏,它會拋出「不適當源對象爲這次行動」
哪有我修復它?
非常感謝,帕特!我添加了控制柄到其中一個形狀,並嘗試粘貼它(不是在錄製宏中的PinX),它的工作! – JleruOHeP 2012-08-06 05:47:33