Visio Guy

Visio Discussions => Shapes & Templates => Topic started by: RuSty on February 07, 2013, 08:38:50 AM

Title: How to quickly delete shape data
Post by: RuSty on February 07, 2013, 08:38:50 AM
How can I quickly delete all shape data?

When I want to delete shape data I must right click on the shape go to Data>Define Shape Data and then delete each row by clicking button delete.
I'm beginner in Visio and maybe there is an another way?
Title: Re: How to quickly delete shape data
Post by: Paul Herber on February 07, 2013, 08:58:23 AM
A quicker way is Open Shapesheet, scroll down to the Shape Data section, right-click on one of the rows and select Delete Section.
How you get to Open Shapesheet depends on which version of VVi you are using, and you will need to be in developer mode.
Open Shapesheet used to be  on the  Wndow menu, but Visio 2010 onwards it is on the Developer tab.
Get into developer mode from thje Options menu.

Another way to delete all the shape data (and can do more than one shape at a time), is to install my SupeUtils for Visio:
http://www.sandrila.co.uk/visio-utilities/ (http://www.sandrila.co.uk/visio-utilities/)
and use menu Super Utils -> Shape -> Delete -> Custom Properties
Title: Re: How to quickly delete shape data
Post by: Surrogate on February 07, 2013, 09:03:57 AM
Hi there,

I am not begginer in visio, but i don't know how delete all fields of shape data by one click using standard visio commands ! Try this macro
Sub RuSty()
Dim sel As Selection
Dim selsh As Shape
Set sel = ActiveWindow.Selection ' create "selection"
For x = 1 To sel.Count           ' iterate all shapes (from first to last) in selection
Set selsh = sel(x)               ' set current selected shape
selsh.DeleteSection visSectionProp ' in current shape delete section "Shape Data", like as via shapesheet :)
Next x
End Sub


PS: Paul,

Thank you, i forget about way via shapeseet ;)
Title: Re: How to quickly delete shape data
Post by: RuSty on February 07, 2013, 09:14:06 AM
Thank you Paul and Surrogate information very helpful. I've tried the utility and macros very convenient. I will use these methods :)
Title: Re: How to quickly delete shape data
Post by: RuSty on February 07, 2013, 09:37:25 AM
Have a new problem)

When I use manually way to delete shape data and then drag new data to the shape, table shown A-Z, but when I use your very fast and convinient way new data that I drag to the shape shown in random order. Don't know why it is happens :(
Title: Re: How to quickly delete shape data
Post by: Surrogate on February 07, 2013, 10:37:45 AM
Quote from: RuSty on February 07, 2013, 09:37:25 AM
Have a new problem)

When I use manually way to delete shape data and then drag new data to the shape, table shown A-Z, but when I use your very fast and convinient way new data that I drag to the shape shown in random order. Don't know why it is happens :(
i dont understand which table you are mean, that shown A-Z ? Please show me your screenshot with this table !
Title: Re: How to quickly delete shape data
Post by: Paul Herber on February 07, 2013, 11:12:15 AM
The order of the data depends on the sort key. What sort key do you have set? You can see this in the Define Shape Data dialog.
How are you dragging the shape data?
Title: Re: How to quickly delete shape data
Post by: Surrogate on February 07, 2013, 11:46:46 AM
i think RuSty use way that described in video
Quote from: RuSty on February 06, 2013, 01:51:30 PM
Quote from: aledlund on February 06, 2013, 12:58:33 PM
consider sessions eight and nine
http://visio.microsoft.com/en-us/Get_Started/How_To/Learn_Visio_2010_from_Visio_MVPs/Pages/default.aspx
al

Thank you. Helpful information
i have slow internet connection and can't see this video :(
Title: Re: How to quickly delete shape data
Post by: RuSty on February 07, 2013, 12:48:11 PM
I made a video. My mistake that it was not problem of sort. When I use macros and then drag new data, old data returns.

Sorry for my bad english, hope video show the problem.

http://www.youtube.com/watch?v=5oUYSDSR1XI (http://www.youtube.com/watch?v=5oUYSDSR1XI)
Title: Re: How to quickly delete shape data
Post by: Surrogate on February 07, 2013, 01:36:27 PM
RuSty, I forgot about bug of Visio - when all section deleted and at once and new row. All old rows are return.
Try this code. There deleted not all section immediately, there deleted each row in this section!
If you prefer delete section via shapesheet, please save file after this operation, then deleted rows don't return in section

Sub RuSty()
Dim sel As Selection
Dim sec As Section
Dim selsh As Shape
Set sel = ActiveWindow.Selection ' create "selection"
For x = 1 To sel.Count           ' iterate all shapes (from first to last) in selection
Set selsh = sel(x)               ' set current selected shape
For y = selsh.RowCount(visSectionProp) - 1 To 0 Step -1
selsh.DeleteRow visSectionProp, y ' in current shape delete current row in section "Shape Data"
Next y
Next x
End Sub


My English is little too :)

я забыл про этот баг Визио - если удалить секцию и тут же начать добавлять в нее строки. Все старые строки возвращаются
попробуй этот код, он удаляет не всю секцию, а каждую строку по очереди
Если ты предпочитаешь удалять секцию через Шейпшит, сразу же сохрани файл. Тогда удаленные строки не вернутся

Title: Re: How to quickly delete shape data
Post by: Paul Herber on February 07, 2013, 03:58:40 PM
Your English is better that most other people's Russian (and Estonian)!

Yes, I reported that bug on one of the official forums a few years ago and got flamed by a moderator as it was obviously a fault in my code (I was writing in Delphi and not a real MS approved language).

Title: Re: How to quickly delete shape data
Post by: RuSty on February 08, 2013, 12:07:56 PM
Big thanks macro works. It will save a lot of time for me. I don't know what I would do without this forum :)

Thanks to all again!
Title: Re: How to quickly delete shape data
Post by: Surrogate on February 08, 2013, 12:26:04 PM
Now you know that exist a russian speaking forum too :)
Title: Re: How to quickly delete shape data
Post by: RuSty on February 08, 2013, 12:40:46 PM
yes :)
Title: Re: How to quickly delete shape data
Post by: Yacine on February 08, 2013, 05:30:35 PM
If the shape has no special features, you might consider joining it. Visio will only keep the geometry section.
Title: Re: How to quickly delete shape data
Post by: MikeB on May 14, 2018, 03:18:58 PM
Just to take this a bit further :-)

...how can I delete all shape data in collection of shape apart from one specific field? i.e. I have about 200 shapes that all have the same fields - the first field is named 'AppID' and I want to keep this but delete all others. I guess I have to access at row name and test against that to exclude it?

Any help welcome :-)
Title: Re: How to quickly delete shape data
Post by: Surrogate on May 14, 2018, 11:34:12 PM
Try this code please
Sub MikeB()
Dim shp As Shape ' current shape
Dim sc As Section ' shp's shape data section
Dim rw As Row ' row in shape data section
Dim cnt As Integer ' count or rows in shape data section
Dim r As Integer ' counter
For Each shp In ActivePage.Shapes
If shp.SectionExists(visSectionProp, visExistsAnywhere) Then
' check for shape data section exist for current shape
Set sc = shp.Section(visSectionProp)
' define shape data section variable
cnt = sc.Count
' define how many rows in shape data section
For r = cnt - 1 To 1 Step -1
'iterate rows in section from last to second
' first row in Shape Data section don't delete
' rows index in Visio start from 0 !
Set rw = sc.Row(r)
' define row in shape data section variable
shp.DeleteRow sc.Index, rw.Index
' delete row in shape data section
Next
End If
Next
End Sub
Title: Re: How to quickly delete shape data
Post by: Jayehorn on January 28, 2021, 11:43:12 PM
This has saved me so much time removing data but how can I re-add data?
I'm new to visio and currently using the newest visio version for office 365 apps.
I highlighted all the shapes and used my shortcut key for the macro and it removed on all shapedata at once. I then saved it.
I tried to re-add the shapedata but got the message to drag rows onto page to link data to existing shapes or to add new linked shapes.
Can you help me on this?

Thanks.


Quote from: Surrogate on February 07, 2013, 01:36:27 PM
RuSty, I forgot about bug of Visio - when all section deleted and at once and new row. All old rows are return.
Try this code. There deleted not all section immediately, there deleted each row in this section!
If you prefer delete section via shapesheet, please save file after this operation, then deleted rows don't return in section

Sub RuSty()
Dim sel As Selection
Dim sec As Section
Dim selsh As Shape
Set sel = ActiveWindow.Selection ' create "selection"
For x = 1 To sel.Count           ' iterate all shapes (from first to last) in selection
Set selsh = sel(x)               ' set current selected shape
For y = selsh.RowCount(visSectionProp) - 1 To 0 Step -1
selsh.DeleteRow visSectionProp, y ' in current shape delete current row in section "Shape Data"
Next y
Next x
End Sub


My English is little too :)

я забыл про этот баг Визио - если удалить секцию и тут же начать добавлять в нее строки. Все старые строки возвращаются
попробуй этот код, он удаляет не всю секцию, а каждую строку по очереди
Если ты предпочитаешь удалять секцию через Шейпшит, сразу же сохрани файл. Тогда удаленные строки не вернутся

Title: Re: How to quickly delete shape data
Post by: Surrogate on January 29, 2021, 06:57:47 AM
Quote from: Jayehorn on January 28, 2021, 11:43:12 PM
I highlighted all the shapes and used my shortcut key for the macro and it removed on all shapedata at once. I then saved it.
I tried to re-add the shapedata but got the message to drag rows onto page to link data to existing shapes or to add new linked shapes.
Your shape data have external data links before delete ?
Title: Re: How to quickly delete shape data
Post by: Jayehorn on March 09, 2021, 04:52:46 PM
Quote from: Surrogate on January 29, 2021, 06:57:47 AM
Quote from: Jayehorn on January 28, 2021, 11:43:12 PM
I highlighted all the shapes and used my shortcut key for the macro and it removed on all shapedata at once. I then saved it.
I tried to re-add the shapedata but got the message to drag rows onto page to link data to existing shapes or to add new linked shapes.
Your shape data have external data links before delete ?

Yes. They are linked to an excel spreadsheet.