Free Support Forum - aspose.com

Word crashes after removing headers and footers

After running the following code on certain Word documents to strip the headers and footers, the document will cause Word to lock up or crash. Do you have any suggestions as to why this code would cause this problem?

Thank you.

Dim Sec As Aspose.Word.Section

'----- Create a document to work with
Dim Doc As Aspose.Word.Document = New Aspose.Word.Document(FileName)
'----- Create a builder to work with our document
Dim builder As DocumentBuilder = New DocumentBuilder(Doc)

For Each Sec In builder.Document.Sections
Sec.ClearHeadersFooters()
Sec.DeleteHeaderFooterShapes()
Next

'----- Save the doc
Doc.Save(FileName)

Hi,

Thank you for your interest in Aspose.Word.

Please make sure that you use the latest version of the component and if it doesn't help, attach at least one of the problematic documents.