Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-17-2022, 04:36 AM
jonoww jonoww is offline Updating the header and footer of many documents Windows 10 Updating the header and footer of many documents Office 2019
Novice
Updating the header and footer of many documents
 
Join Date: Jan 2022
Posts: 3
jonoww is on a distinguished road
Default Updating the header and footer of many documents

I am trying to update the header and footer size on a large number of Word documents within sub-folders. The macro I am using is as below:

Code:
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    With Selection.PageSetup
        .HeaderDistance = CentimetersToPoints(2.6)
        .FooterDistance = CentimetersToPoints(2.6)
    End With
This works, however I need to run it on many documents. I have found a batch processes add-in from gmayor Graham Mayor - Home Page

I have placed the code into a function so it can be used as a custom process within the add-in. The process runs with no errors but when I open the amended documents the header/footer appears unchanged. I'm not sure why as it will work when manually ran. Hoping someone can assist.



Code:
Function HeaderFooter(oDoc As Document) As Boolean
On Error GoTo Err_Handler
'Do Something with oDoc here. e.g.,"

    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    With Selection.PageSetup
        .HeaderDistance = CentimetersToPoints(2.6)
        .FooterDistance = CentimetersToPoints(2.6)
    End With
    
HeaderFooter = True
lbl_Exit:
Exit Function
Err_Handler:
Select Case Err.Number
'Case Is = "Your handled errors e.g., 5109"
Case Else
HeaderFooter = False
Resume lbl_Exit
End Select
End Function


Thanks
Reply With Quote
  #2  
Old 01-17-2022, 04:55 AM
gmayor's Avatar
gmayor gmayor is offline Updating the header and footer of many documents Windows 10 Updating the header and footer of many documents Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You missed the comment you reproduced in the code.
Code:
Function HeaderFooter(oDoc As Document) As Boolean
    On Error GoTo Err_Handler
    'Do Something with oDoc here. e.g.,"
    With oDoc
        With .PageSetup
            .HeaderDistance = CentimetersToPoints(2.6)
            .FooterDistance = CentimetersToPoints(2.6)
        End With
        HeaderFooter = True
    End With
lbl_Exit:
    Exit Function
Err_Handler:
    HeaderFooter = False
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 01-17-2022, 05:43 AM
jonoww jonoww is offline Updating the header and footer of many documents Windows 10 Updating the header and footer of many documents Office 2019
Novice
Updating the header and footer of many documents
 
Join Date: Jan 2022
Posts: 3
jonoww is on a distinguished road
Default

Thanks for that, think I accidentally removed part of the code when testing. Looks to be working although only on blank documents, I assume something is preventing the change on my regular templates.
Reply With Quote
  #4  
Old 01-17-2022, 05:57 AM
gmayor's Avatar
gmayor gmayor is offline Updating the header and footer of many documents Windows 10 Updating the header and footer of many documents Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you wish you can send the document to my web site and I will take a look,
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding text to the header and footer without removing all other content in the header and footer digitalelise Word VBA 2 10-23-2019 02:58 AM
Updating the header and footer of many documents Include header and footer formatting when using IF conditional includes of separate documents anakaine Mail Merge 3 11-06-2015 09:51 PM
Dynamic Header / Footer for ALL documents Abri Word 3 08-13-2015 04:40 AM
Header and footer aligned in the footer area ashiqghfr Word 2 07-23-2015 01:14 AM
header/footer problems only in certain documents Endzone Word 5 08-15-2012 01:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft