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

Joined: 27 Jan 2006 Posts: 3
|
Posted: Fri Jan 27, 2006 6:49 am Post subject: Macros for printing 2-copies of sheet3 |
|
|
Hello.
First of oll sorry for my english.
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 |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Sat Jan 28, 2006 4:51 pm Post subject: |
|
|
| Insert another sheet behind sheet3 with linked content. |
|
| Back to top |
|
 |
noranthon Super User

Joined: 07 Jul 2005 Posts: 3318
|
Posted: Sun Jan 29, 2006 7:44 pm Post subject: |
|
|
I can't help with a macro, but the print dialog lets you specify the number of copies you want.  |
|
| Back to top |
|
 |
pika4u Newbie

Joined: 27 Jan 2006 Posts: 3
|
Posted: Mon Jan 30, 2006 3:58 am Post subject: |
|
|
| noranthon wrote: | I can't help with a macro, but the print dialog lets you specify the number of copies you want.  |
I know, but i want to print 2-copies of sheet by click on one button and it is not possible without macro.  |
|
| Back to top |
|
 |
pika4u Newbie

Joined: 27 Jan 2006 Posts: 3
|
Posted: Mon Jan 30, 2006 4:00 am Post subject: |
|
|
| noranthon wrote: | I can't help with a macro, but the print dialog lets you specify the number of copies you want.  |
Sorry, I not understand you  |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Mon Jan 30, 2006 12:41 pm Post subject: |
|
|
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 |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Mon Jan 30, 2006 1:03 pm Post subject: |
|
|
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 |
|
 |
|