|
|
Thread Tools | Display Modes |
#1
|
||||
|
||||
Batch applying a macro to remove Header and Footer using Batch Auto Addin
Greetings, i've been reading this thread https://www.msofficeforums.com/word-...directory.html and i've been trying to adapt this macro:
Code:
Sub DeleteHeadFoot() Dim oHF As HeaderFooter Dim oSection As Section For Each oSection In ActiveDocument.Sections For Each oHF In oSection.Headers oHF.Range.Delete Next For Each oHF In oSection.Footers oHF.Range.Delete Next Next End Sub Code:
Function FontChangeArial16Blue(ByRef oDoc As Word.Document) As Boolean On Error GoTo Err_Handler With oDoc.Range.Font .Size = 16 .Name = "Arial Unicode MS" .Color = wdColorBlue End With FontChangeArial16Blue = True lbl_Exit: Exit Function Err_Handler: FontChangeArial16Blue = False Resume lbl_Exit End Function Code:
Function DeleteHeadFoot(ByRef oDoc As Word.Document) As Boolean Dim oHF As HeaderFooter Dim oSection As Section On Error GoTo Err_Handler For Each oSection In ActiveDocument.Sections For Each oHF In oSection.Headers oHF.Range.Delete Next For Each oHF In oSection.Footers oHF.Range.Delete Next Next DeleteHeadFoot = True lbl_Exit: Exit Function Err_Handler: DeleteHeadFoot = False Resume lbl_Exit End Function |
#2
|
||||
|
||||
Change
Code:
For Each oSection In ActiveDocument.Sections Code:
For Each oSection In oDoc.Sections
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
||||
|
||||
Thank you very much, that was it, it's working as intended
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Batch replace Header and Footer and QuickStyle | Artmax | Word VBA | 14 | 01-11-2024 05:36 PM |
Batch change header text which is in a table | marafubu | Word VBA | 1 | 05-16-2018 04:52 AM |
Remove Compatibility Mode on DOCX files (batch) | w64bit | Word | 17 | 02-01-2015 06:02 AM |
Trying to create a macro to batch edit hyperlinks | martinlest | Excel Programming | 5 | 01-09-2015 09:34 AM |
How do I remove header and footer | captn1 | Word | 2 | 09-04-2010 04:14 PM |