If I delete the user Section, then add it back, it seems to retain old fields

Started by Visisthebest, February 08, 2022, 04:58:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

I have some shapes with user sections where I need to reorder the fields.

Easiest seems to be to delete the user section, then add it again, as Microsoft writes about Shape.DeleteSection:
"When you delete a ShapeSheet section, all rows in the section are automatically deleted."

https://docs.microsoft.com/en-us/office/vba/api/visio.shape.deletesection

Doing this in plain VBA, from the errors I gather that existing user rows actually stick around as I get errors using the old row names.

Is this something anyone has run in to? It seems old rows from the old section stick around somehow. Can't replicate reliably what's happening yet but weird behavior for sure.

Visio 2021 Professional

Visisthebest

If I just delete all the rows instead of deleting the section I get none of the 'ghost user rows' issue indicated above.
Visio 2021 Professional

Paul Herber

As far as I understand it, when a section is removed then re-added, the contents of the section are restored from the master shape. Inheritance.

Electronic and Electrical engineering, business and software stencils for Visio -

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

Visisthebest

Thank you Paul that must be why I'm getting these fields back!

As you can see:

Microsoft didn't document this for the Shape.DeleteSection function:
https://docs.microsoft.com/en-us/office/vba/api/visio.shape.deletesection

or the AddSection function:
https://docs.microsoft.com/en-us/office/vba/api/visio.shape.addsection

but yes that is exactly what is happening!
Visio 2021 Professional