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

Macros for printing 2-copies of sheet3

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
pika4u
Newbie
Newbie


Joined: 27 Jan 2006
Posts: 3

PostPosted: Fri Jan 27, 2006 6:49 am    Post subject: Macros for printing 2-copies of sheet3 Reply with quote

Hello. Very Happy
First of oll sorry for my english. Embarassed
I need to print two copies of sheet3 by click on one button. I tried to write mocros in Calc by Service/Macros/Write macros, but it is unsuccessfully. Please help me.
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Sat Jan 28, 2006 4:51 pm    Post subject: Reply with quote

Insert another sheet behind sheet3 with linked content.
Back to top
View user's profile Send private message
noranthon
Super User
Super User


Joined: 07 Jul 2005
Posts: 3318

PostPosted: Sun Jan 29, 2006 7:44 pm    Post subject: Reply with quote

I can't help with a macro, but the print dialog lets you specify the number of copies you want. Sad
Back to top
View user's profile Send private message
pika4u
Newbie
Newbie


Joined: 27 Jan 2006
Posts: 3

PostPosted: Mon Jan 30, 2006 3:58 am    Post subject: Reply with quote

noranthon wrote:
I can't help with a macro, but the print dialog lets you specify the number of copies you want. Sad

I know, but i want to print 2-copies of sheet by click on one button and it is not possible without macro. Sad
Back to top
View user's profile Send private message
pika4u
Newbie
Newbie


Joined: 27 Jan 2006
Posts: 3

PostPosted: Mon Jan 30, 2006 4:00 am    Post subject: Reply with quote

noranthon wrote:
I can't help with a macro, but the print dialog lets you specify the number of copies you want. Sad

Sorry, I not understand you Question
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Mon Jan 30, 2006 12:41 pm    Post subject: Reply with quote

When printing by Menu: File > Print... while recording a macro I get:
Code:

sub fooPrint
   ' get access to the document
   DocumentModel = ThisComponent
   DocumentView = DocumentModel.getCurrentController()
   DocumentFrame = DocumentView.Frame
   ' the dispatcher service is used to send commands from the
   ' document frame to the underlaying office application
   Dispatcher = CreateUnoService("com.sun.star.frame.DispatchHelper")

   Dim Args1(0) As New com.sun.star.beans.PropertyValue
   Args1(0).Name = "ToPoint"
   Args1(0).Value = "D15"
   Dispatcher.executeDispatch(DocumentFrame, ".uno:GoToCell" ,"c2b_WORK" ,0 ,Args1())

   Dim Args2(2) As New com.sun.star.beans.PropertyValue
   Args2(0).Name = "FileName"
   Args2(0).Value = "/home/andreas/fooprint.ps"
   Args2(1).Name = "Copies"
   Args2(1).Value = 2
   Args2(2).Name = "Collate"
   Args2(2).Value = False
   Dispatcher.executeDispatch(DocumentFrame, ".uno:Print" ,"c2b_WORK" ,0 ,Args2())
end sub

The relevant property-setting is:
Args2(1).Name = "Copies"
Args2(1).Value = 2

This is set to a postscript file because there is no printer running right now.
Args2(0).Name = "FileName"
Args2(0).Value = "/home/andreas/fooprint.ps"
You setup your printer @Tools > Options > OOo >Printer with 2 separate options in the calc-submenu.
@File > Print you specify print-options for printing the active document.
@Calc-menu Format >Print Ranges ... you specify ranges to be printed or not.
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Mon Jan 30, 2006 1:03 pm    Post subject: Reply with quote

This can be assigned to the "Before Print" event of this document. Tools > Settings > Events.
It makes a temporary copy of the 3rd sheet in case you want to print the whole document with a second copy of 3rd sheet.
Code:

Sub before_print()
With thisComponent.sheets
   sName = .getbyindex(2).getName
   .copyByName(sName,sName &"_tmp",3)
end with
 rm_TmpSheet()
End Sub

There is no "After Print" event accessible through the normal UI-setup, but you may use this with some other event like "Status Canged" or you remove this manually.
Code:

Sub rm_TmpSheet()
with thisComponent.sheets
   sName = .getbyindex(2).getName & "_tmp"
   if .hasByName(sName) then .removeByName(sName)
end with
End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc 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