Visio GlueTo Method Returns "Inappropriate target object for this action"
I am trying to glue a shape to another in Visio using GlueTo
Here is the code
Set trgObj = Cell.shape.Document.Masters("Trigger").Shapes(1)
Dim x As shape
Set x = ActivePage.Drop(trgObj, flowConnector.CellsU("PinX"), flowConnector.CellsU("PinY"))
Dim vsoCell1 As Visio.Cell
Dim vsoCell2 As Visio.Cell
Set vsoCell1 = x.CellsU("PinX")
Set vsoCell2 = Application.ActiveWindow.Page.Shapes.ItemFromID(flowConnector.ID).CellsSRC(7, 1, 0)
vsoCell1.Gl开发者_开发知识库ueTo vsoCell2
'The following code I obtained through running a macro in visio
'Dim vsoCell1 As Visio.Cell
'Dim vsoCell2 As Visio.Cell
'The following is the equivalent to x
'Set vsoCell1 = Application.ActiveWindow.Page.Shapes.ItemFromID(51).CellsU("PinX")
'The following is the equivalent to flowConnector
'Set vsoCell2 = Application.ActiveWindow.Page.Shapes.ItemFromID(12).CellsSRC(7, 1, 0)
'vsoCell1.GlueTo vsoCell2
it returns "Inappropriate target object for this action", but what is strange is that the code i am using I obtained from recording a macro. I can't understand why the code works when I record it in a macro but when I use it it doesn't. If anyone can offer any help I would greatly appreciate it.
I have figured out the problem instead of using the code which was provided by the macro
Dim vsoCell1 As Visio.Cell
Dim vsoCell2 As Visio.Cell
Set vsoCell1 = x.CellsU("PinX")
Set vsoCell2 = Application.ActiveWindow.Page.Shapes.ItemFromID(flowConnector.ID).CellsSRC(7, 1, 0)
rather use the following
Dim vsoCell1 As Visio.Cell
Dim vsoCell2 As Visio.Cell
Set vsoCell1 = Application.ActiveWindow.Page.Shapes.ItemFromID(x.ID).CellsSRC(visSectionConnectionPts, 0, 0)
Set vsoCell2 = Application.ActiveWindow.Page.Shapes.ItemFromID(flowConnector.ID).CellsSRC(visSectionConnectionPts, 1, 0)
where
visSectionConnectionPts, 0, 0)
0, 0 references cell 0 in the connection points or the x cell
and
visSectionConnectionPts, 1, 0)
references the cell 1 or y cell in the connection points
精彩评论