Wednesday, October 21, 2009

OpenXml – Delete Previous Section Changes

Dependencies:

DocumentFormat.OpenXml.dll (version 2.0.3930.0)

Imports:

DocumentFormat.OpenXml.WordProcessing

DocumentFormat.OpenXml.Packaging

Code Snippet
  1. Private Sub DeletePreviousSectionChanges(ByRef myDoc As WordprocessingDocument)
  2. Dim sectPrChanges As List(Of PreviousSectionProperties) = myDoc.MainDocumentPart.Document.Descendants(Of PreviousSectionProperties)().ToList()
  3. For Each sectPrChange As PreviousSectionProperties In sectPrChanges
  4. sectPrChange.Remove()
  5. Next
  6. myDoc.MainDocumentPart.Document.Save(myDoc.MainDocumentPart.GetStream(FileMode.Create))
  7. End Sub

No comments:

Post a Comment

Calling .NET From COM Originally posted by Mikec276 on C Sharp Friends It might be hard to convince your IT manager to let you build y...