In Page Style I want to activate the option: ‘Same content on first page’ , through a python macro.
But this error is showing:
(<class ‘AttributeError’>: FirstIsShared
what am I doing wrong? The same approach works for the other attributes.
custom_pg_style.FirstIsShared = True
My macro:
import uno
def test_header(*args):
doc = XSCRIPTCONTEXT.getDocument()
sheets = doc.Sheets
main_sheet = sheets[0]
#Create new Page Style
pg_styles = doc.StyleFamilies['PageStyles']
if pg_styles.hasByName('Custom') == False:
page_style = doc.createInstance('com.sun.star.style.PageStyle')
pg_styles.insertByName('Custom', page_style)
#Apply Page Style
main_sheet.PageStyle = 'Custom'
#Modify Page Style
custom_pg_style = pg_styles[main_sheet.PageStyle]
#custom_pg_style.HeaderOn = True #it works
#custom_pg_style.HeaderIsShared = True #it works
#https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1style_1_1PageProperties.html#a7381f863bce3a1e7a0ba3838a2636364
custom_pg_style.FirstIsShared = True