Log in

View Full Version : XML corruption with "track changes" Word 2003



falconwing
08-12-2008, 02:06 PM
I wrote a VBA project that has been working fine for my users for several months now. They fire up the macro and use the userforms to add, modify, and delete XML structures embedded in the document.

Recently I had a user come to me with problems running the macro. I looked at the XML Structure task pane and sure enough the structure was corrupted.

When I looked at the document I saw the active part of the document had valid XML. However, what surprised me was that the deleted XML also was showing up in the XML structure in the Task Pane! What was different in this case was the user had turned on "Track Changes".

I allowed word to save the document as XML "even if not valid" so I could look at the raw wordml. This properly showed the XML data as deleted and inserted. What was interesting was when I looked at the "save data only", which eliminated anything my code was doing. The "save data only" data looked like the XML structure Task Pane, and like the data my macro was retrieving by walking the xml nodes - the deleted XML was sitting there!

Good example (deletes disappear):
<Reqt>
<Review_Status>...</Review_Status>
</Reqt>

Bad example:
<Reqt> [deleted]
<Review_Status>...</Review_Status> [deleted]
<Reqt>
<Review_Status>...</Review_Status>
</Reqt>
</Reqt> [deleted]


Based on this behavior, I assume this is a bug in Word. Other than turning track changes off when the macro runs, I've not seen any easy way around this problem. Any ideas out there?

Thanks,
FalconWing

falconwing
08-13-2008, 05:36 AM
The wordML with track changes looks correct to me, and it displays the text correctly. However, Word does not treat deleted XML any differently in track changes mode so you get it all when you walk through the XML nodes, look at the XML Structure in the Task Pane, and you get it all when you "save data only", so I call that a bug. :content: