[Solved] Calc Macro to set printer parameters?

Creating a macro - Writing a Script - Using the API

[Solved] Calc Macro to set printer parameters?

Postby GWS » Thu Jul 28, 2011 6:26 pm

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   Expand viewCollapse view
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
GWS
 
Posts: 137
Joined: Sat Sep 05, 2009 3:46 pm

Re: Calc Macro to set printer prameters?

Postby Villeroy » Thu Jul 28, 2011 6:56 pm

Code: Select all   Expand viewCollapse view
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
User avatar
Villeroy
Volunteer
 
Posts: 30153
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests