Phil Hibbs wrote:
I've been trying to learn OOo scripting, and so far I've learned a few
things by finding examples. For instance, to open a text file and read
from it, you have to do something like this:

    FilePickerDlg = createUnoService( "com.sun.star.ui.dialogs.FilePicker" )
    FilePickerDlg.appendFilter( "DSX Files", "*.dsx" )
    selected = FilePickerDlg.execute()
    Files = FilePickerDlg.getFiles()
    FileName = ConvertFromURL( Files(0) )
    Doc = StarDesktop.CurrentComponent
    Sheet = Doc.Sheets.getByName("Control")
    SFA = createUnoService( "com.sun.star.ucb.SimpleFileAccess" )
    InFile = SFA.openFileRead( FileName )
    TextInputStream = createUnoService("com.sun.star.io.TextInputStream")
    TextInputStream.setInputStream(InFile)
    TextLine = TextInputStream.readLine()
    Sheet.getCellByPosition(0, 0).String = TextLine

First of all, that's a lot more complex than in Excel:

    importfile = Application.GetOpenFilename("DSX Files (*.dsx), *.dsx")
    Open importfile For Input As #1
    Line Input #1, TextLine
    Cells(0, 0) = TextLine

Secondly, where am I supposed to find out all that createUnoService
stuff? I could only write the above by spending three evenings
searching the interwebs for examples and asking either here or on a
newsgroup.

I think OOo is great, but I'm really struggling with this. Are any of
the other scripting languages easier to use than OOo Basic?

In our department we once used MS Word for output for producing reports and runsheets, actually accessing it through COM so that the driving program was largely outside of MS Office. (We usually used FoxPro.)

When switching to OpenOffice.org, we had to rewrite most of these applications, and found that OpenOffice.org scripting was indeed quite a bit harder, far more complex. However it also seemed to be less buggy. But it was usually not possible to create satisfactory code by recording a macro and then modifying the saved code while that is a normal method in MS Word.

I suspect this difficulty with the macro languages is why some people get frustrated with OpenOffice.org. (Of course, many users hardly ever create or use macros.)

Whether some of the other languages now provided with OpenOffice.org might be easier really depends on your personal experience. I did not find the Basic part of the language difficult at all, rather the UNO part of it.

The main resource for OpenOffice scripting is http://www.pitonyak.org/oo.php . You should also download the OpenOffice.org SDK from http://download.openoffice.org/2.4.0/sdk.html .

Understanding UNO is very important, and may be very difficult.

See also http://wiki.services.openoffice.org/wiki/Uno and http://api.openoffice.org/ .

Jim Allan



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

Reply via email to