Search code examples
libreofficelibreoffice-calclibreoffice-basic

LibreOffice Calc macro - How to remove header and footer in given sheet?


Default header and footer show up when I print out invoice created by macro. I want to remove them in my macro.


Solution

  • I found this is the way to turn header and footer off:

    Dim oDoc As Object
    Dim oSheet As Object
    Dim oStyles As Variant
    Dim oPstyle As Variant
    
    oDoc=ThisComponent
    
    oSheet=oDoc.Sheets.getByName("Sheet1")
    
    oStyles=oDoc.StyleFamilies.getByName("PageStyles")
    oPstyle=oStyles.getByName(oSheet.PageStyle)
    oPstyle.HeaderOn=FALSE
    oPstyle.FooterOn=FALSE