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

OOCalc Print Range Macro... How do I do it?

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


Joined: 19 Jul 2006
Posts: 5

PostPosted: Wed Jul 19, 2006 10:21 am    Post subject: OOCalc Print Range Macro... How do I do it? Reply with quote

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
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Wed Jul 19, 2006 11:43 am    Post subject: Reply with quote

<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 https://forum.openoffice.org
Back to top
View user's profile Send private message
allenrmaher
General User
General User


Joined: 19 Jul 2006
Posts: 5

PostPosted: Wed Jul 19, 2006 12:09 pm    Post subject: Reply with quote

Thanks!
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 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