[Solved] Macro Set Page Format To Portrait

Keyboard macros or custom scripts

[Solved] Macro Set Page Format To Portrait

Postby misitu » Thu Jun 23, 2016 4:25 am

Hello.

My charts are wider than deep. I am saving as a spreadsheet and also exporting to PDF. The problem arises in that I cannot see how to set to PORTRAIT in a way that the PDF Export finds acceptable.

What is happening is that the PDF is produced in landscape, truncating the charts to "print" in parts on different pages.

In manual mode, setting the Format>Page> to Portrait, and tweaking the X's and Y's appropriately, I can print the two charts on their own pages with no overlap, truncation, etc.

I have this piece of code
Code: Select all   Expand viewCollapse view
dim PrintOptions(0) as new com.sun.star.beans.PropertyValue
PrintOptions(0).Name = "PaperOrientation"
PrintOptions(0).Value = com.sun.star.view.PaperOrientation.LANDSCAPE   
but I am not clear how to link it to the worksheets.

There are two sheets, the data sheet where all the data is loaded, and the charts sheet where the charts are produced. The latter is sheet(0) and the other is sheet(1).

I have tried dropping these lines into several likely places but I always end up with the IOException message, pointing to the "Save as .ods" line:
Code: Select all   Expand viewCollapse view
ThisComponent.storeAsURL(storeAsUrl, args_ODS())


All assistance welcome and gratefully received.

Thanks
David
Last edited by misitu on Thu Jun 23, 2016 4:23 pm, edited 1 time in total.
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
User avatar
misitu
 
Posts: 89
Joined: Mon Dec 16, 2013 5:34 am
Location: Trujillo - La Libertad - Perú

Re: Macro Set Page Format To Portrait

Postby Zizi64 » Thu Jun 23, 2016 6:39 am

The print orientation and the page (sheet) orientation are not same properties.
You need use a landscape sheet style (page style) instead of the portrait one.

You can apply a page style by a macro or manually.
Tibor Kovacs, Hungary; LO4.4.7, LO5.4.7 on Win7x64Prof.
PortableApps, winPenPack: LO3.3.0-LO6.1.0 and AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 6983
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Macro Set Page Format To Portrait

Postby misitu » Thu Jun 23, 2016 4:22 pm

Thanks, Zizi.

From the brevity of your reply I figured the question had already been answered.

This was all that's needed, apart from this prologue

In sum, following my
Code: Select all   Expand viewCollapse view
   oSheets.insertNewByName("Chart", 0)
, where the specific sheet is defined, I add from the above
Code: Select all   Expand viewCollapse view
  oStyleFamilies = ThisComponent.StyleFamilies 'ThisComponent refers to the document that called the macro
  oPageStyles = oStyleFamilies.getByName("PageStyles")  'oPageStyles is a collection of all of the Page styles
  DefPage = oPageStyles.getByName("Default")
'
DefPage.IsLandscape = True
DefPage.Width = 29700 
DefPage.Height = 21000

and BINGO, I now have an acceptable landscape layout. :D

For anyone following this up, I would comment that you do need both the IsLandscape (which changes the radio button on the Format>Page> dialog, and also the Width and Height since, as Bernard said earlier,
The API is not very smart...
, it is indeed I would say the result of a bit of faulty oversight somewhere in the API translator (probably a bit of lazy reuse of a variable)... never mind, it all works now thanks to yourself and Bernard in the earlier post.

It is not difficult to work out that you guys KNOW when a question has already been answered :super:

Best regards
David
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
User avatar
misitu
 
Posts: 89
Joined: Mon Dec 16, 2013 5:34 am
Location: Trujillo - La Libertad - Perú


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests