| View previous topic :: View next topic |
| Author |
Message |
allenrmaher General User

Joined: 19 Jul 2006 Posts: 5
|
Posted: Wed Jul 19, 2006 10:21 am Post subject: OOCalc Print Range Macro... How do I do it? |
|
|
Ok I have a former MS Spread sheet which has many many complex things going on, those have all been converted, but a simple one is giving me trouble.
I can't find the syntax in the docs to have a macro print a range (I have only two parts of two sheets that need printing the other sheets just generate the data in the print ranges)
It is simple enough to do this without a macro, but this sheet is aimed at joe shmoe non spreadsheet user...
In the excel version of the macro this was accomplished with:
Edit... this is what the excel version comes up as under oocalc...
| Code: |
Sub PrintSkills_Click()
Skills = ThisComponent.Sheets.getbyname("Skills")
PrintSkills = ThisComponent.Sheets.getbyname("PrintSkills")
' Select print area to one or two pages depending on how many skills there were
If Skills.getCellRangeByName("num_skill_rows").Value > 108 Then
PrintSkills.PrintAreas = PrintSkills.getCellRangeByName("$A$1:$N$112")
Else
PrintSkills.PrintAreas = PrintSkills.getCellRangeByName("$A$1:$N$56")
End If
dim emptyRange()
Skills.setPrintAreas(emptyRange)
End Sub
Sub PrintStats_Click()
Sheets("Stats").PrintOut
End Sub
Sub PrintAll_Click()
Sheets("Stats").PrintOut
PrintSkills_Click
End Sub |
Really just looking to find out what kind of syntax is needed to print a predefined range |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Wed Jul 19, 2006 11:43 am Post subject: |
|
|
<API-doc=com.sun.star.sheet.XPrintAreas>
setPrintAreas
void
setPrintAreas( [in] sequence< ::com::sun::star::table::CellRangeAddress > aPrintAreas );
</API-doc>
| Code: |
REM declare a sequence (array) of one cellrange address
Dim arrayPrintAreas(0) as new com.sun.star.table.CellRangeAddress
Dim oSheetAddress
REM the address of a sheet includes the sheet-index
oSheetAddress = PrintSkills.getRangeAddress
arrayPrintAreas(0).sheet = oSheetAddress.Sheet
REM range starts at A1 and ends somwehre in column N
arrayPrintAreas(0).StartColumn = 0
arrayPrintAreas(0).StartRow = 0
arrayPrintAreas(0).EndColumn = 13
If Skills.getCellRangeByName("num_skill_rows").Value > 108 Then
arrayPrintAreas(0).EndRow = 111
else
arrayPrintAreas(0).EndRow = 55
endif
PrintSkills.setPrintAreas(arrayPrintAreas())
|
_________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
allenrmaher General User

Joined: 19 Jul 2006 Posts: 5
|
Posted: Wed Jul 19, 2006 12:09 pm Post subject: |
|
|
| Thanks! |
|
| Back to top |
|
 |
|