OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Howto set paper size in open office basic?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
tweety
Newbie
Newbie


Joined: 29 Jul 2004
Posts: 2

PostPosted: Thu Jul 29, 2004 11:00 am    Post subject: Howto set paper size in open office basic? Reply with quote

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
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Thu Jul 29, 2004 11:54 am    Post subject: Reply with quote

The following may help:

http://www.oooforum.org/forum/viewtopic.php?t=9075&highlight=paper+size

Also, you may need to set the paper size that is used by the document itself. You probably need to set this in the page style for the document.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
tweety
Newbie
Newbie


Joined: 29 Jul 2004
Posts: 2

PostPosted: Fri Jul 30, 2004 1:20 am    Post subject: Reply with quote

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
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Fri Jul 30, 2004 4:01 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Fri Jul 30, 2004 4:10 am    Post subject: Reply with quote

This is how to get the page dimensions. Guess how to set them Smile
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
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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