Reply in-line.

On Mon, 2005-05-30 at 20:58, Chris Benatar wrote:
> In Response to: Ian Laurenson,
> 
> The code listed below didn't work when I tried it. The original XL file
> has 2 sheets setup and this code prints out the whole of the second
> sheet. I can see that the area on the first sheet gets highlighted ie.
> selected, but it doesn't printout. 
> 
Oops! Sorry about that, there were two mistakes:
1. I didn't clear all existing print ranges for each sheet.
2. Incorrectly set the print range.

The revised macro:

sub Monday
'Clear all other print ranges
for i = 0 to thisComponent.sheets.count - 1
        thisComponent.sheets(i).setPrintAreas(Array())
next

oCurController = ThisComponent.CurrentController
oActiveSheet = oCurController.ActiveSheet      
 
'     Range("A47:AL126").Select
oCurController.select(oActiveSheet.getCellRangeByName("A1:B3"))

'     Selection.PrintOut Copies:=1, Collate:=True
dim mPrintProperties(1) as new com.sun.star.beans.PropertyValue
mPrintProperties(0).name = "Copies"
mPrintProperties(0).value = 1
mPrintProperties(0).name = "Collate"
mPrintProperties(0).value = true
'The following will work because we know that there is only one
selection
oActiveSheet.setPrintAreas(array(ocurController.getSelection.getRangeAddress))
thisComponent.print(mPrintProperties())
 
'     ActiveWorkbook.Save
thisComponent.store
end sub

> >> '     ActiveWorkbook.Save
> >> thisComponent.store
> Thanks for this bit - seems to work fine. Much appreciated. As simple
> as the VBA code - yay!!
> 
> >> By the way, I think your subject for this posting is wrong. The
> macro
> >> language BASIC is close to identical between OOo BASIC and VBA. The
> >> underlying object models (APIs) are very different.
> 
> Yes, I do agree with you on this although I do feel that the object
> model is the way most people would see the language ie. although it is
> an extension of it, it is a pretty critical one. Not sure what would be
> involved in changing the languages interface to the object model or
> even if it can be done but it certainly would be welcomed. 

Currently I don't have the skills to alter the core source code so I
have concentrated on what I can do - write documentation and macros.

But I agree it would be nice if OOo BASIC could have similar defaults to
VBA, such as if a range is specified it refers to the currently active
sheet, of the currently active document. However, for me this is a low
priority as I can, more or less, simulate that with variables.

Other (comparatively minor) problems  with the design of the API that I
have encountered include:
* In Writer searching is at a document level thus coding for searching
within a selection is extremely tedious and the resulting code is slow.
* Having an enumeration for PageLayout that doesn't include an option
for "none" when you simply aren't concerned about duplex printing.

Some might say that print ranges for spreadsheet documents also fall
into this category.

However, to me, there were even bigger problems with the MSO API.

A much higher priority for me is having more in the API such as the
ability to easily have docked/floating windows in extensions.


> 
> >> In defence of the OOo API:
> >> I can do things that were virtually impossible with Microsoft Office
> >> (MSO). For example, my "reveal codes" macro simply wouldn't be
> possible
> >> in MSO.
> 
> But intruth for 99.9% of users this level of power and sophistication
> is not required and it comes at a price.

To me the flexibility is imperative (I actually want more). By having
wrappers you get the ease of use without sacrificing the flexibility.
> 
> >> The API is designed to be accessible from a wide range of languages.
> 
> Which are all incomprehensible to the average user.
> 
> >> My attempt at a solution has been to put together the wiki
> >> http://ext.openoffice.org.nz. In that wiki I and others have written
> >> functions (together with documentation) that people can copy and
> paste
> >> into their own macros. Eventually I hope that we will have a
> sufficient
> >> library of routines that writing macros for OOo is at least as easy
> as
> >> it is in VBA.
> 
> VERY much appreciated. Can't something like this be integrated into the
> language - I gather that the UNO stuff is on these lines but what you
> are doing seems like what is needed. 
> 
Once there is a comprehensive library of routines, then that library and
documentation could be included in the OOo distribution.

> If I ever get good enough at this to write anything useful, I'll add to
> your Wiki, whats a Wiki?

See http://wiki.org/wiki.cgi?WhatIsWiki

In short:
A wiki is a web site, but any[1] person viewing the site, can alter the
web site within their browser by clicking an Edit button. Different
wikis have slightly different formats but basically they follow the
conventions used in text mail messages.

[1] Some wikis require the user to be registered before they can edit
the site. http://ext.openoffice.org.nz does not currently require the
user to be registered.

Have a look at the wiki, and try editing a page - let the list know what
you think.

Thanks, Ian


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to