[Solved] Runtime error using objects

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
budo_flieger
Posts: 3
Joined: Sun Nov 23, 2008 10:13 pm

[Solved] Runtime error using objects

Post by budo_flieger »

Hi,
I try to create my first subroutine. Using OpenOfficer.org 3 CALC "Extras - Makros - Makros verwalten - OpenOffic.org Basic...". I copied varios example code form the manual, but every time the execution stops, when the line contains a command using objects. The following error is displayed: "BASIC Laufzeitfehler Eigenschaft oder Methode nicht gefunden" (means: BASIC runtime error attribute or method not found).

Example (from BASIC guide):

sub Ha

Dim Doc As Object
Dim Sheet As Object
Dim CellRange As Object

rem Globalscope.BasicLibraries.LoadLibrary("Tools")
rem GlobalScope.DialogLibraries.LoadLibrary( "Standard" )

Doc = StarDesktop.CurrentComponent
Sheet = Doc.Sheets(0) ' <- error on this line !!!???
Sheet = Doc.Sheets.getByName(1)
Sheet = Doc.Sheets.getByName("Sheet 1")
CellRange = Sheet.getCellRangeByName("A1:C15")

end sub

Somewhere I read to insert the commands now marked as comment lines (rem), but it doesn't helped. I use Windows XP. The error occurs on single step and normal execution.

Thanks for help

budo_flieger
Last edited by budo_flieger on Wed Nov 26, 2008 10:44 pm, edited 1 time in total.
OOo 3.0.X on Ms Windows XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Runtime error using objects

Post by Villeroy »

What does symbol Doc refer to?
What is the current component of the StarDesktop?

http://www.pitonyak.org/oo.php
http://development.openoffice.org/?cid=926478#BASIC
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
budo_flieger
Posts: 3
Joined: Sun Nov 23, 2008 10:13 pm

Re: Runtime error using objects

Post by budo_flieger »

Hi,
I expect, that Doc refers to the currently opened CALC file and Sheets adresses the currently opened spreadsheet. Doesn't it?
My original intend is to work with the cells in this spreadsheet by adding strings from cells of an other spreadsheet.

budo_filieger
OOo 3.0.X on Ms Windows XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Runtime error using objects

Post by Villeroy »

You can not do any programming at all if you are not able to evaluate your symbols. Search for "Xray", install it, use it. Refer to the links I posted and read other people's code. There you may find the special Basic variable "ThisComponent", which refers to the last active document (including help documents!) when used in global context. In document context, ThisComponent always refers to the document containing the Basic code. http://wiki.services.openoffice.org/wik ... ment_basic
No, this is not even similar to VBA.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
budo_flieger
Posts: 3
Joined: Sun Nov 23, 2008 10:13 pm

Re: Runtime error using objects

Post by budo_flieger »

yeah, that's it....

thanks, your recommendation was helpful (I didn't find this page on my own search for help...)

budo_flieger
OOo 3.0.X on Ms Windows XP
Post Reply