To delete all headers and footers in a LibreOffice Writer document, follow these steps:
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:
You can write a simple LibreOffice Basic macro to remove headers and footers from all page styles in your document. Here’s how:
basicSub 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
If your document primarily uses the Default page style, you can:
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:
basicSub 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
Alt + F11 or Tools > Macros > Organize Macros > LibreOffice Basic).Tools > Macros > Run Macro).This should resolve the runtime error and disable all headers and footers in your document at once.
Vibe can make mistakes. Check answers. Learn more