Hi, everyone
Who could do me a favor to teach me how to use Asposes.Words to remove all the headers and footers in the doc in VB.net?
Thanks!
Hi, everyone
Who could do me a favor to teach me how to use Asposes.Words to remove all the headers and footers in the doc in VB.net?
Thanks!
Hi there,
Thanks for your inquiry. Please use following code example to remove the headers and footers of document.
Dim doc As New Document(MyDir + "in.docx")
For Each section As Section In doc.Sections
section.HeadersFooters.Clear()
Next
doc.Save(MyDir + "Out v16.8.0.docx")
Hi, Tahir Manzoor,
Thanks for your demo.
And what is the demo for removing header or footer only?
Hi there,
Thanks for your inquiry. Please use following code example to remove the header or footers of document. Hope this helps you.
Dim doc As New Document(MyDir + "in.docx")
For Each section As Section In doc.Sections
For Each hf As HeaderFooter In section.HeadersFooters
'Remove Footers
If hf.HeaderFooterType = HeaderFooterType.FooterPrimary Or hf.HeaderFooterType = HeaderFooterType.FooterFirst Or hf.HeaderFooterType = HeaderFooterType.FooterEven Then
hf.Remove()
End If
'''Remove Headers
''If hf.HeaderFooterType = HeaderFooterType.HeaderPrimary Or hf.HeaderFooterType = HeaderFooterType.HeaderFirst Or hf.HeaderFooterType = HeaderFooterType.HeaderEven Then
'' hf.Remove()
''End If
Next
Next
doc.Save(MyDir + "Out v16.8.0.docx")
Hi,Tahir Manzoor
Thank you very much!
And could you pay attention to my other questions there?
Hi there,
Thanks for your inquiry. Please use the commented code snippet shared in my previous post to remove the header of document.
If you still face problem, please share some more detail about your query. We will then provide you more information on this along with code.