My first question in this forum:
I created a report in LibreOffice Base. The report itself works fine.
I want to execute this report automatically when LibreOffice is started with the database. I try to do that with the following macro:
Dim rptName as String
Dim DB as Object
rptName = “rptMessdaten”
msgbox "open report " & rptName
'further code till end
I connected this macro with the OnOpen event of LO Base. This also works properly, as is proofed by the MsgBox.
When executing the line DB = ThisDatabaseDocument, I get the following error: BASIC Laufzeitfehler. Variable nicht definiert. (BASIC runtime error, variable not defined). The undefined variable is ThisDatabaseDocument. The macro is part of the Standard.Module1 area of the database, as it should be, and not in My Macros. I also execute this macro manually by F5, or by a button in a form. Always the same message.
I found in this forum several topics where people had a similar problem. They exchanged ThisDatabaseDocument with ThisComponent and tell that it worked after that modification. I also tried that, with no result. Also ThisComponent is undefined. This means, in my application both ThisDatabaseDocument and ThisComponent are always undefined. I got my code from this forum where in many places it is described why it fails when run under My Macros but works when run in the macro area of the database.
As it works for others, I assume i make a mistake which I do not see. And I hope somebody also might see what I do wrong.
My environment is:
- Ubuntu 18.04 with LibreOffice 184.108.40.206
- Windows 10 with LibreOffice 220.127.116.11
In both environment the problem is identical.