| View previous topic :: View next topic |
| Author |
Message |
PsychoticBoredom Power User

Joined: 04 Nov 2005 Posts: 68 Location: Houston, Texas
|
Posted: Wed Dec 07, 2005 1:32 pm Post subject: Export selection to PDF in landscape mode? |
|
|
Help! How can I modify the macro below to export a selected range to PDF in landscape mode? The default is set to portrait.
'----------------------------------------------------------------------
sub new_pdf
rem
'----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem
'----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem
'----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
'args1(0).Value = "$BG$2:$BJ$21"
args1(0).Value = "SEPTMBUILD"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem
'----------------------------------------------------------------------
dim args2(3) as new com.sun.star.beans.PropertyValue
args2(0).Name = "URL"
args2(0).Value = "file:///ips/fd/sw/ad/ard/asab25_er3/se_ptm.pdf"
args2(1).Name = "FilterName"
args2(1).Value = "calc_pdf_Export"
args2(2).Name = "FilterData"
args2(2).Value =
Array(Array("UseLosslessCompression",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ReduceImageResolution",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportNotes",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Selection",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE))
args2(3).Name = "SelectionOnly"
args2(3).Value = true
dispatcher.executeDispatch(document, ".uno:ExportTo", "", 0, args2())
end sub
'------------------------------------------------------------------------------------------ _________________ "Think like a genius. Act like a fool." |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Wed Dec 07, 2005 2:52 pm Post subject: |
|
|
| I believe you cannot set to landscape mode in this macro. Use format / page / landscape in calc, then run your macro ... |
|
| Back to top |
|
 |
PsychoticBoredom Power User

Joined: 04 Nov 2005 Posts: 68 Location: Houston, Texas
|
Posted: Tue Dec 13, 2005 7:47 am Post subject: |
|
|
I have gotten good results with this:
args2(4).Name = "PaperOrientation"
args2(4).Value = com.sun.star.view.PaperOrientation.LANDSCAPE _________________ "Think like a genius. Act like a fool." |
|
| Back to top |
|
 |
PsychoticBoredom Power User

Joined: 04 Nov 2005 Posts: 68 Location: Houston, Texas
|
Posted: Tue Dec 13, 2005 8:12 am Post subject: |
|
|
I fixed it. The following code exports a selection from a calc spreadsheet to a pdf file in either portrait or landscape mode (whichever you specify). Here's what I used:
rem *************************************************************************************
rem *************************************************************************************
Sub pdf_selection
dim oSheet as object, document as object, dispatcher as object
dim filename as string
' SPECIFY YOUR SHEET NAME HERE
oSheet = ThisComponent.Sheets.getByName("STD")
ThisComponent.CurrentController.setActiveSheet(oSheet)
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
'clears the current print area
dispatcher.executeDispatch(document, ".uno:DeletePrintArea", "", 0,Array()) 'new
rem
----------------------------------------------------------------------
dim odoc
dim Printeroptions(4) as new com.sun.star.beans.PropertyValue
odoc = thisComponent
'adjust printer settings
Printeroptions(0).Name = "Printer Name"
Printeroptions(0).Value = "Default"
Printeroptions(1).Name = "PaperOrientation"
'SPECIFY PORTRAIT OR LANDSCAPE HERE
Printeroptions(1).Value = com.sun.star.view.PaperOrientation.PORTRAIT
Printeroptions(2).Name = "Copies"
Printeroptions(2).Value = 1
Printeroptions(3).Name = "Selection"
Printeroptions(3).Value = true
Printeroptions(4).Name = "Collate"
Printeroptions(4).Value = true
odoc.Printer = Printeroptions()
'clears the current print area
dispatcher.executeDispatch(document, ".uno:DeletePrintArea", "", 0,Array())
rem
----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
' PUT IN YOUR RANGE OR NAMED RANGE HERE
args1(0).Value = "CRITSUM"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
'sets the current print area
dispatcher.executeDispatch(document, ".uno:DefinePrintArea", "", 0,args1())
' PATHNAME TO YOUR OUTPUT FILE
filename = "file:///ips/fd/sw/ad/ard/asab25_er3/pdf_files/critsum.pdf"
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "FilterName"
args2(0).Value = "calc_pdf_Export"
thisComponent.storeToURL(filename, args2())
'clears the current print area
dispatcher.executeDispatch(document, ".uno:DeletePrintArea", "", 0,Array())
End Sub _________________ "Think like a genius. Act like a fool."
Last edited by PsychoticBoredom on Wed Dec 14, 2005 5:56 am; edited 1 time in total |
|
| Back to top |
|
 |
Rory Power User


Joined: 04 Nov 2004 Posts: 51 Location: Brasilia DF, Brasil
|
Posted: Wed Dec 14, 2005 5:15 am Post subject: |
|
|
Just a note for anyone finding this post in the future,
When i query odoc.Printer I fin only the values
| Code: | Printeroptions(0).Name = "Printer Name"
Printeroptions(0).Value = "Default" |
| Code: | Printeroptions(1).Name = "PaperOrientation"
Printeroptions(1).Value = 0 |
Note that .value = 0 equivelent to PORTRAIT
Note that .value = 1 equivelent to LANDSCAPE
Or you could use
Printeroptions(1).Value = com.sun.star.view.PaperOrientation.PORTRAIT
Printeroptions(1).Value = com.sun.star.view.PaperOrientation.LANDSCAPE
| Code: | Printeroptions(2).Name = "PaperFormat"
Printeroptions(2).Value = 0 |
here I found many possible values regarding page sizes 0=A4 / 1 = A5
I never found m,ore values in the printer array than these three _________________ Rory
/Cries
OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2) |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|