Delete Old Shape Data, Link to New Data

Started by Blake Dot C, August 16, 2017, 03:33:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Blake Dot C

I'm having a problem trying to delete old shape data, and linking those shapes to new data.  It seems like there's no super efficient way to delete old shape data, so I'm using the following macro:

Sub New1()
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

This in fact does delete the old shape data, verified by an empty shape data box; however, the old text still remains on the shape.  Once I've linked new data to the Visio document, and drag and drop it into the existing shape, nothing changes and the old text is still there, even though the data shape box now displays the new data.  I just had this working a few minutes ago and now I'm lost.  It will not work anymore.

Surrogate

Quote from: Blake Dot C on August 16, 2017, 03:33:30 PM
This in fact does delete the old shape data, verified by an empty shape data box; however, the old text still remains on the shape.
When you delete these shape data rows, visio application engine delete link between text field and missing shape data
Quote from: Blake Dot C on August 16, 2017, 03:33:30 PMOnce I've linked new data to the Visio document, and drag and drop it into the existing shape, nothing changes and the old text is still there, even though the data shape box now displays the new data.  I just had this working a few minutes ago and now I'm lost.  It will not work anymore.
but now these field have only text value, which not depend with your shape data. you need add fields again !

why you delete rows, not replace shape data values ?

Blake Dot C

Ok I figured it out again.  Man I just do not like Visio.  Even with data imported with the exact same headers, order, and constituents, Visio defaults to new Data Fields for the graphic.  When I go in to change the Data Field..BOOM..Visio resets all the proportions of my pre-existing shape to default aka....text all over the place.  By naming my new data fields the exact same thing used with those same shapes before I can get Visio to update my shapes with the new data and not change the text proportions.  Otherwise, if you have to update the Data Field within the graphic, Visio resets all text positions.

Calmormy

You make me more knowledgeable. I like all of you very much

wapperdude

While I think this topic is dead, for someone who might come across it...

The original methodology is faulty.  Rather than delete the rows, thus deleting all dependencies upon those rows, either delete the contents, or just update and replace the contents.  If the contents change dramatically, there could be some resizing issues which might need attention.

The fact that the "old text" still displays suggests that there are additional issues.  To resolve such issues, a simple upload would have been most helpful.

Wapperdude
Visio 2019 Pro