[Solved] Calc Macro to set printer parameters?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
GWS
Posts: 137
Joined: Sat Sep 05, 2009 3:46 pm

[Solved] Calc Macro to set printer parameters?

Post by GWS »

Have sub to set up my Epson CX6000 printer bt it does not set landscape mode or reduction value?

Have been all over the net etc with no results.
Hade the " page.IsLandscape = true"statement in before to no avail.

Code: Select all

Sub FormatPrinterLandscape
Dim sS		as String  	'$     'Style name
Dim oStyle 	as Object	'The current page style


  REM Use the currently active sheet to obtain the page style.
  REM In a Calc document, the current controller knows which sheet is active.
  REM SET SHEET SCALE TO 83%
  sS = ThisComponent.CurrentController.getActiveSheet().PageStyle
  oStyle = ThisComponent.StyleFamilies.getByName("PageStyles").getByName(sS)
  oStyle.PageScale = 83        'Scale document to 83%
  
pageStyles = thisComponent.StyleFamilies.getByName("PageStyles")
page = pageStyles.getByName("Default")

REM SET PAGE SIZE TO 8.5 X 11.0 IN MILLIMETERS
page.width = 27932     '29700
page.height = 21584  '21000

REM SET MARGINS LEFT = .75" RIGHT, TOP, BOTTOM = .5"
page.LeftMargin = 1905
page.RightMargin = 1270
page.TopMargin = 1270
page.BottomMargin = 1270

REM Set Page Orientation TO LANDSCAPE
'page.IsLandscape = true

Dim printerOption(0) As New com.sun.star.beans.PropertyValue
printerOption(0).Name = "PaperOrientation"
printerOption(0).Value = com.sun.star.view.PaperOrientation.LANDSCAPE
thisComponent.Printer = printerOption()

'MsgBox "Set printer to Landscape"



REM NO Header
page.HeaderIsOn = False

rem Add a Footer
page.FooterIsOn = True

End Sub
Would appreciate any ideas.

Gary
Last edited by GWS on Fri Jul 29, 2011 12:36 am, edited 1 time in total.
OpenOffice 2.3.1 on Windows Vista
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Calc Macro to set printer prameters?

Post by Villeroy »

Code: Select all

Sub Snippet()
  sh = ThisComponent.Sheets.getByIndex(0)
  sh.PageStyle = "MyIncrediblePageStlyeWithScaleAndOrientationAndEverything"
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply