[Solved] BASIC Runtime Error in Calc Macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
khanlon
Posts: 13
Joined: Tue Oct 24, 2017 7:36 pm

[Solved] BASIC Runtime Error in Calc Macro

Post by khanlon »

When I run the following CALC macro it works.

Sub Insert_Rows(Sheet_Idx, Row, Count)

Rem *** The following three lines added to run macro independently
Sheet_Idx = 0
Row = 62
Count = 1
Rem ***
Sheets = thisComponent.Sheets
Sheet = Sheets.getByIndex(Sheet_Idx)
Sheet.Rows.insertByIndex(Row, Count)

End Sub

However, when it is called from a function it receives the error below. Can someone tell me why this happens? Thanks.

"Basic Runtime Error. An exception occurred. Type:com.sun.star.uno.RuntimeException Message.
Last edited by khanlon on Wed Oct 25, 2017 1:08 am, edited 2 times in total.
OpenOffice 4.1.4 / Windows 10
User avatar
Zizi64
Volunteer
Posts: 11358
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: BASIC Runtime Error in Calc Macro

Post by Zizi64 »

Please upload a sample ODS file with the embedded FULL macro code, to see: how you call the function, how you pass the parameters, what variable type parameters are you using, etc...


Do you want to call the function from a cell?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Lupp
Volunteer
Posts: 3548
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: BASIC Runtime Error in Calc Macro

Post by Lupp »

The code works for me as expected in AOO Calc 4.1.3.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
khanlon
Posts: 13
Joined: Tue Oct 24, 2017 7:36 pm

Re: BASIC Runtime Error in Calc Macro

Post by khanlon »

Yes, I am calling it from my user written function in a calc cell.
OpenOffice 4.1.4 / Windows 10
User avatar
MrProgrammer
Moderator
Posts: 4901
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: BASIC Runtime Error in Calc Macro

Post by MrProgrammer »

Using macro as a function. Why isn't it working?

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
khanlon
Posts: 13
Joined: Tue Oct 24, 2017 7:36 pm

Re: [Solved] BASIC Runtime Error in Calc Macro

Post by khanlon »

Thanks for the information / help.
OpenOffice 4.1.4 / Windows 10
Post Reply