Using a macro to change from portrait to landscape in calc

I’m trying to figure out how to change the format of a page from portrait to landscape using a LibreOffice Basic macro.
When I use the record feature it’ll record me getting to the page format pop-up, but not the actual toggle and enter

Thanks for any help

Use page styles.

Create a page style called “Landscape”, which includes all the page info:

Format → Styles and Formatting → Click on the Page Styles icon → Rightclick on the list → New

Then apply it to your sheet:

oSheet = ThisComponent.Sheets.getByName("Sheet1")
oSheet.PageStyle = "Landscape"

It is a little convoluted for just setting landscape but it enables you to set everything else as well, which is probably what you really need to do anyway :slight_smile:

Andrew