delete all connection point of shape and add new and glue the shapes

Started by suhaspatil3007, December 30, 2011, 05:55:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

suhaspatil3007

hi all,

i am trying to delete all connection point of shape using following code

   For currentRow = 0 To shape.Section(Visio.VisSectionIndices.visSectionConnectionPts).Count - 1
            shape.DeleteRow Visio.VisSectionIndices.visSectionConnectionPts, visRowFirst + currentRow
    Next currentRow


and add new connection point to shape and
trying to glue the newly created connection point with connector using following code

Set beginX = connector.CellsSRC(visSectionObject, visRowXForm1D, vis1DBeginX)
Set temp = shape.CellsSRC(visSectionObject, currentRow, Visio.VisCellIndices.visCnnctX)

beginX.GlueTo temp


but it throws error saying inappropriate object

can any one put some light on this part????

thanks in advance

Jumpy

I don't know, if it relates to your error, but as a dump question: What value is in currentRow at the time you Set Temp?

As to deleting all rows: Don't know if neccessary in VBA, but I think it is a best practice, to delete backwards:
For currentRow = shape.Section(Visio.VisSectionIndices.visSectionConnectionPts).Count - 1 To 0 Step -1

Or instead of deleting all the rows you could delete the whole section, recreate it and insert a new row in it. Maybe that is faster.

suhaspatil3007

currentrow is just counter of for loop
e.g
For currentRow = 0 To connectionPoints.count - 1
Set masterObj = ActiveDocument.Masters.ItemU("Dynamic Connector")
        Set connector = ActivePage.Drop(masterObj, 1, 1)

Set beginX = connector.CellsSRC(visSectionObject, visRowXForm1D, vis1DBeginX)
Set temp = shape.CellsSRC(visSectionObject, currentRow, Visio.VisCellIndices.visCnnctX)

beginX.GlueTo temp

next  currentRow

the point here is it wont allow to glue connector to connection point cell of shape and i dont know why.

but visio allows this
beginX.GlueTo shape.CellsSRC(visSectionObject, visRowXFormOut, visXFormPinX) -- no error for this line

JuneTheSecond

May be, the reason is Visio bug in CellsSRC.
In
     Set beginX = myConnector.CellsSRC(visSectionObject, visRowXForm1D, vis1DBeginX)
     Set temp = myShape.CellsSRC(visSectionObject, currentRow, Visio.VisCellIndices.visCnnctX)
beginX and temp are changed to something like integer.

You have found a greate bug in Visio.

Next codes run correctly.

    Set beginX = myConnector.Cells("BeginX")
    Set temp = myShape.Cells("Connections.X1")   
    beginX.GlueTo temp



Best Regards,

Junichi Yoda
http://june.minibird.jp/

aledlund

Jumpy's correct, you have to delete backwards from the end of the list.

Jumpy

Maybe you should show more code instead of just snippets.
I would guess that your indexes are wrong and you so try to connect to a connection point (row) that doesn't exist. That's the nice thing with JuneTheSeconds code, where he uses shape.Cells(""). If the named cell exists it will work.

JuneTheSecond

Now I see, please replace
Set temp = shape.CellsSRC(visSectionObject, currentRow, Visio.VisCellIndices.visCnnctX)
into
Set temp = Shape.CellsSRC(visSectionConnectionPts, currentRow, visCnnctX)
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Browser ID: smf (is_webkit)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 260 (show)
Files included: 34 - 1317KB. (show)
Memory used: 1171KB.
Tokens: post-login.
Cache hits: 13: 0.00161s for 26,582 bytes (show)
Cache misses: 2: (show)
Queries used: 16.

[Show Queries]