Wednesday, October 21, 2009

OpenXml – Delete Form Protection

Dependencies:

DocumentFormat.OpenXml.dll (version 2.0.3930.0)

Imports:

DocumentFormat.OpenXml.WordProcessing

DocumentFormat.OpenXml.Packaging

Code Snippet
  1. Private Sub DeleteFormProtection(ByRef myDoc As WordprocessingDocument)
  2. Dim formProts As List(Of FormProtection) = myDoc.MainDocumentPart.Document.Descendants(Of FormProtection)().ToList()
  3. For Each formProt As FormProtection In formProts
  4. formProt.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...