New
How to delete all headers and footers in LibreOffice?
Nov 19, 2:42pm

To delete all headers and footers in a LibreOffice Writer document, follow these steps:

1. Open the Header/Footer Editor

  • Double-click on the header or footer area in your document.
  • Alternatively, go to Insert > Header or Insert > Footer to open the editor.

2. Delete the Content

  • Select all the text or objects inside the header or footer.
  • Press Delete or Backspace to remove the content.

3. Remove the Header/Footer Itself

  • If you want to completely remove the header or footer (not just clear its content):
    • Go to Format > Page.
    • In the Page Style dialog, select the Header or Footer tab.
    • Uncheck the Header on or Footer on option.
    • Click OK to apply.

4. Repeat for All Page Styles

  • If your document uses multiple page styles (e.g., "First Page," "Default," etc.), repeat the process for each style:
    • Go to Format > Styles and Formatting (or press F11).
    • Right-click the page style and select Modify.
    • In the Header or Footer tab, uncheck the options and click OK.

5. Check for Section-Specific Headers/Footers

  • If your document has sections, ensure you repeat the process for each section.

6. Save Your Document

Nov 19, 2:42pm
Is it possible to do this at once instead of doing it manually for all page styles?
Nov 19, 2:43pm

In LibreOffice Writer, there is no built-in "one-click" method to delete all headers and footers across all page styles at once. However, you can speed up the process using one of these approaches:


1. Use a Macro (Automation)

You can write a simple LibreOffice Basic macro to remove headers and footers from all page styles in your document. Here’s how:

Steps to Run a Macro:

  1. Open the Macro Editor:
    • Press Alt + F11 (or go to Tools > Macros > Organize Macros > LibreOffice Basic).
  2. Create a New Macro:
    • In the Macro Editor, create a new module and paste the following code:
basic
Sub DeleteAllHeadersFooters Dim oDoc As Object Dim oStyles As Object Dim oStyle As Object oDoc = ThisComponent oStyles = oDoc.StyleFamilies.getByName("PageStyles") For Each oStyle In oStyles oStyle.HeaderIsOn = False oStyle.FooterIsOn = False Next oStyle End Sub
  1. Run the Macro:
    • Close the editor and run the macro (Tools > Macros > Run Macro).
    • This will disable headers and footers for all page styles in the document.

2. Modify the Default Page Style

If your document primarily uses the Default page style, you can:

  1. Go to Format > Page.
  2. In the Header and Footer tabs, uncheck Header on and Footer on.
  3. Click OK to apply to all pages using the Default style.

3. Use Find & Replace (Limited)

  • Press Ctrl + F to open Find & Replace.
  • Click More Options and enable Search for Styles.
  • Search for Header or Footer content and replace it with nothing.
  • This only clears content but does not disable headers/footers.

Which Method Should You Use?

  • For a one-time fix: Use the macro.
  • For a single page style: Manually disable headers/footers in Format > Page.
  • For complex documents: The macro is the fastest way.
Nov 19, 2:43pm
When running the macro, I get a BASIC runtime error: "Property or method not found:StyleFamilies."
Nov 19, 2:48pm

The error occurs because the correct property name in LibreOffice Basic is StyleFamilies, but the way to access page styles is slightly different. Let's fix the macro to ensure it works correctly.

Here is the corrected macro:

basic
Sub DeleteAllHeadersFooters Dim oDoc As Object Dim oPageStyles As Object Dim oStyle As Object Dim i As Integer oDoc = ThisComponent oPageStyles = oDoc.getStyleFamilies().getByName("PageStyles") For i = 0 To oPageStyles.getCount() - 1 oStyle = oPageStyles.getByIndex(i) oStyle.HeaderIsOn = False oStyle.FooterIsOn = False Next i End Sub

How to Use the Macro:

  1. Open the LibreOffice Basic Macro Editor (Alt + F11 or Tools > Macros > Organize Macros > LibreOffice Basic).
  2. Create a new module and paste the code above.
  3. Run the macro (Tools > Macros > Run Macro).

What This Macro Does:

  • It loops through all page styles in your document.
  • For each style, it turns off both headers and footers.

This should resolve the runtime error and disable all headers and footers in your document at once.

Nov 19, 2:48pm

This Chat is read-only. Login to resume chatting.

Sub DeleteAllHeadersFooters Dim oDoc As Object Dim oStyles As Object Dim oStyle As Object oDoc = ThisComponent oStyles = oDoc.StyleFamilies.getByName("PageStyles") For Each oStyle In oStyles oStyle.HeaderIsOn = False oStyle.FooterIsOn = False Next oStyle End Sub
Sub DeleteAllHeadersFooters Dim oDoc As Object Dim oPageStyles As Object Dim oStyle As Object Dim i As Integer oDoc = ThisComponent oPageStyles = oDoc.getStyleFamilies().getByName("PageStyles") For i = 0 To oPageStyles.getCount() - 1 oStyle = oPageStyles.getByIndex(i) oStyle.HeaderIsOn = False oStyle.FooterIsOn = False Next i End Sub