| View previous topic :: View next topic |
| Author |
Message |
amurphy96822 OOo Enthusiast


Joined: 08 May 2005 Posts: 141 Location: Honolulu
|
Posted: Thu Feb 16, 2006 1:05 pm Post subject: printing current page of document only |
|
|
Hello all: I spend all day printing single pages of long documents. I start with Control-P which brings up the dialogue; now if I forget to do Alt-G which selects the current page number (under Print Range, Pages), it starts out to print the whole document which is a big mess. If I create a keystroke macro, I get the following:
| Code: |
sub print_one
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(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Copies"
args1(0).Value = 1
args1(1).Name = "RangeText"
args1(1).Value = "26"
args1(2).Name = "Collate"
args1(2).Value = false
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args1())
end sub
|
which does not work unless the page number happens to be "26" as it was when I created this. I realize I need to declare a varable for "vcurrentpage" or similar, but how do I "get" the value of the current page to make this work? Thanks for the help. Btw, this is much easier in wordperfect that has "system" variable like currentpage. _________________ WinXP or Vista or PCLinuxOs; usually Compaq Presario laptop/Dell Inspiron 1150/various desktops usually OpenOffice v3 |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8982 Location: Lexinton, Kentucky, USA
|
Posted: Thu Feb 16, 2006 3:16 pm Post subject: |
|
|
| Code: | Sub Print_one
Dim oDoc,oVC,CurrentPage
oDoc = ThisComponent
oVC = oDoc.CurrentController.getViewCursor
CurrentPage = Str(oVC.getPage)
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Copies"
args1(0).Value = 1
args1(1).Name = "RangeText"
args1(1).Value = CurrentPage
args1(2).Name = "Collate"
args1(2).Value = false
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args1())
End Sub |
This assumes that the cursor it actually in the page you are looking at on screen because you can actually be looking at a page and the cursor can be somewhere else. A case of, "If things can go wrong, they will go wrong."  |
|
| 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
|