create row gone crazy

Started by perry59, March 05, 2015, 09:38:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

perry59

I have a routine which converts a connector to a "wire".
I am working on a routine which will "upgrade" my older version wire to a newer version. To do this I am deleting the user and custom prop tables and rebuilding them. It is working fine for the most part, but for some reason there are some "wires" which get really goofed up. Stepping through the code I see the old table being deleted. When I go to recreate them something weir happens.
On this line of code:

intPropRow = VsoShape.AddNamedRow(visSectionProp, strLocalRowName, VisRowIndices.visRowProp)

instead of creating a single row in the custom properties table, its adding ALL the rows which were previously deleted!!
how the heck can that happen ???

If anyone can give a hint, I'd much appreciate it!  (passing the shape around ByRef didn't help)
thanks
what, me worry?

Paul Herber

It's a problem that has been around for a long time. You need to delete each row individually, then add all your new rows.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

perry59

Ah, so I'm not going crazy  :o
Thanks

now I need to make a function to delete a table, row by row
what, me worry?

Paul Herber

and remember that you have to delete from row <rowcount-1> downto 0.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

perry59

Quote from: Paul Herber on March 05, 2015, 11:25:39 PM
and remember that you have to delete from row <rowcount-1> downto 0.

Thanks!
what, me worry?

perry59

Well, I tried that. Made a little routine which deleted the rows, one by one, starting from the last row.
then it deletes the section.
But the crazy behavior persists. As soon as I add a row to the section all the old rows reappear  >:(
this of course hoses the rest of the macro, which I really need to get working!
what, me worry?

wapperdude

Hi Perry,

From your opening comments, I get the impression that most of the wires behave as expected wrt the upgrading process.  It's only a few that misbehave, correct?  Wondering if perhaps those few have somehow become corrupt?

I did a very simple test, didn't even delete the section, and ran into no problems.  Code is as follows:
Sub Del_Add_Props()

    ActivePage.Shapes.ItemFromID(1).OpenSheetWindow
    ActiveWindow.Shape.DeleteRow visSectionProp, 3
    ActiveWindow.Shape.DeleteRow visSectionProp, 2
    ActiveWindow.Shape.DeleteRow visSectionProp, 1
    ActiveWindow.Shape.DeleteRow visSectionProp, 0
   
    ActiveWindow.Shape.AddNamedRow visSectionProp, "RowA", visdefault
    ActiveWindow.Shape.AddNamedRow visSectionProp, "RowB", visdefault
    ActiveWindow.Shape.AddNamedRow visSectionProp, "RowC", visdefault
    ActiveWindow.Shape.AddNamedRow visSectionProp, "RowD", visdefault

End Sub


The add row syntax is slightly different than what you're using.  Might want to give this a try, see if makes any difference.

HTH
Wapperdude
Visio 2019 Pro

Paul Herber

Just delete the rows, you don't have to delete the section.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

perry59

Thanks guys!
it seems to be working good now :)
I'm not sure if it was getting rid of the delete section (really wasn't necessary after deleting all the rows)
or the different add row syntax or both, but its behaving!
BTW, is there a reason for the two different add row functions (addrow, addnamedrow)?
is one better than the other?

thanks again!
perry
what, me worry?