locked
PowerShell or VBscript to remove header or footer from Excel and PowerPoint files RRS feed

  • Question

  • Hi Fellows.

    Has any one came across a script to remove header or footer from Excel and PowerPoint file? I have got a script for MS Word but not able to find anything for Excel and PowerPoint. any help would be highly appreciated.

    Regards.


    J.A

    Saturday, October 20, 2018 6:37 PM

All replies

  • Hi JunaidAhmedpk,

    Thanks for visiting our forum. Then here we mainly focus on general issues about Office desktop client. Since your query is related to script, I'll move your thread to the dedicated MSDN forum for Excel for better response:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Regards,

    Yuki Sun


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, October 22, 2018 2:03 AM
  • Hi J.A,

    Please try the following code to remove header from Excel:

    Option Explicit
    Sub Remove_Header()
        Dim cnt    As Integer
        Dim i      As Integer
        cnt = ActiveWorkbook.Worksheets.Count - 1
        Application.ScreenUpdating = False
        For i = 2 To cnt
        Worksheets(i).Select
            With ActiveSheet.PageSetup
                .CenterFooter = ""
               'etc
            End With
        Next i
        Application.ScreenUpdating = True
    End Sub
    

    Hopefully it helps you.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Monday, October 22, 2018 7:18 AM
  • Hi J.A,

    Thanks for your asking. Did you resolve your issue? If the post helps you, you can mark it as answer and close the post.

    Thank you for understanding. If you have any question, or update, please feel free to let us know.

    I wish you a happy life!

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Wednesday, October 24, 2018 6:41 AM
  • Hi Yuki.

    Thank you. How can I use this script to remove header from multiple Excel files?

    I have bulk Excel files in one folder and require the script to traverse the folder and remove header one by one for each file.

    Thanks.


    J.A

    Friday, October 26, 2018 12:08 PM
  • Hi J.A,

    Sorry for the late reply.

    The VBA code provided from my previous post only apply removing header from multiple worksheets in one Excel file.

    If you want to remove header from multiple Excel files, please try the code as below:

    < "headerfile.csv" set /P "HEADER="
    for %%F in ("*.csv") do (
        if /I not "%%~F"=="headerfile.csv" (
            > "%%~F.tmp" echo(%HEADER%
            >>"%%~F.tmp" < "%%~F" (set /P = & findstr "^")
            move /Y "%%~F.tmp" "%%~F"
        )
    )

    For more information, please review the following link:

    Remove header from multiple csv files

    Hopefully it helps you.

    Best Regards,

    Yukil


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Monday, October 29, 2018 8:36 AM