| View previous topic :: View next topic |
| Author |
Message |
tweety Newbie

Joined: 29 Jul 2004 Posts: 2
|
Posted: Thu Jul 29, 2004 11:00 am Post subject: Howto set paper size in open office basic? |
|
|
Hello,
I'm trying to set up a word to pdf converter. I found a macro for Open Office but I still have a different tricky problem: Openoffice recognizes the pages in the wrong size, they are a bit to small. As a result of this, the converter generates from one pages two, althoug the second one is nearly empty.
Is there a way, to set the paper size with a line in the macro. 2 - 3 cm would be enough for my purposes.
Thanks in advance
Christian
Germany |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
|
| Back to top |
|
 |
tweety Newbie

Joined: 29 Jul 2004 Posts: 2
|
Posted: Fri Jul 30, 2004 1:20 am Post subject: |
|
|
Hello,
you are right, I've to set the paper size of the document, but not the printer paper size (which is explained in the link).
Has anyone an idea to do this with Basic in a macro? I tried the macro recorder, but that generates a code, which opens the dialog for setting the paper size. Is there a way to set a value automatically?
Heres the generated code:
| Code: |
sub Main
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 ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PageDialog", "", 0, Array())
end sub
|
Thanks
Christian |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Fri Jul 30, 2004 4:01 am Post subject: |
|
|
Now that I am reading your original question again, it occurs to me that you are probably already using the correct paper size. Does it make sense to simply change the margins?
I assume that you have the document set to use A4 and your printer is set to A4 (unless you are in the USA and everything is Letter). Telling OO that the paper size is a bit larger will not change the paper size, it will only change the way that OO will format the text. This brings me back to changing the margins.
Comments? _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Fri Jul 30, 2004 4:10 am Post subject: |
|
|
This is how to get the page dimensions. Guess how to set them
| Code: | Sub PageDimensions
Dim oDoc
Dim oStyle
Dim sPageStyle As String
Dim s As String
oDoc = ThisComponent
sPageStyle = oDoc.CurrentController.getViewCursor().PageStyleName
oStyle = oDoc.StyleFamilies.getByName("PageStyles").getByName(sPageStyle)
s = "Left Margin = " & CStr(oStyle.LeftMargin / 2540.0) & " inches" & CHR$(10) & _
"Right Margin = " & CStr(oStyle.RightMargin / 2540.0) & " inches" & CHR$(10) & _
"Width = " & CStr(oStyle.Width / 2540.0) & " inches" & CHR$(10) & _
"Top Margin = " & CStr(oStyle.TopMargin / 2540.0) & " inches" & CHR$(10) & _
"Bottom Margin = " & CStr(oStyle.BottomMargin / 2540.0) & " inches" & CHR$(10) & _
"Height = " & CStr(oStyle.Height / 2540.0) & " inches" & CHR$(10) & _
"" & CHR$(10) &_
"Left Margin = " & CStr(oStyle.LeftMargin / 1000.0) & " cm" & CHR$(10) & _
"Right Margin = " & CStr(oStyle.RightMargin / 1000.0) & " cm" & CHR$(10) & _
"Width = " & CStr(oStyle.Width / 1000.0) & " cm" & CHR$(10) & _
"Top Margin = " & CStr(oStyle.TopMargin / 1000.0) & " cm" & CHR$(10) & _
"Bottom Margin = " & CStr(oStyle.BottomMargin / 1000.0) & " cm" & CHR$(10) & _
"Height = " & CStr(oStyle.Height / 1000.0) & " cm" & CHR$(10)
MsgBox s
End Sub |
_________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
|