wordpress hit counter
Using Track Revisions while removing elements from a document - WordprocessingML - Formats - OpenXML Developer

Using Track Revisions while removing elements from a document

Formats

Discussions about working with different Open XML Formats

Using Track Revisions while removing elements from a document

  • rated by 0 users
  • This post has 3 Replies |
  • 1 Follower
  • I have a document that I'm loading into memory and I want to remove some of the elements from the document.  However, I want to use Track Revisions so that the elements aren't actually removed, they're just struck through and then later somebody can accept those changes.  So I'm reading the document into memory, adding a new TrackRevisions element with Val = BooleanValues.True to the Settings collection, calling document.MainDocumentPart.DocumentSettingsPart.Settings.Save(), and then removing my elements by calling myElement.Remove();  Unfortunately, when I then save the document back to the file system and open it in word, the elements have been completely removed from the document instead of being struck through.

    Does anybody know what I'm doing wrong?  Is it possible to use TrackRevisions while modifying the document pro grammatically?  I will be needing to add and remove elements to the document, is there a special way that I need to add and remove them for TrackRevisions to work?

    Thanks!
  • Hi there

    I think this might be the issue, once you finish reading the file into memoryStream, the cursor will be set to the end.

    So try to set the position of the curosr of the streamwriter to 0 then try it again.

    Cheers
  • I'm not sure I understand exactly what you mean? Can you clarify a bit?

    Thanks!
  • From what I can tell, this isn't possible. I created a Word document manually and turned Track Changes on in the document. I then created a program to read in that document, delete the first paragraph, and save it back to the file system.

    When I run my program and then reopen the document, Track Changes is still on but the first paragraph has been removed entirely instead of being struck through.

    Does anybody have any other suggestions on what to try? Is there something I need to do instead of calling .Remove() on the element?
Page 1 of 1 (4 items)