[Solved] BASIC Runtime Error in Calc Macro

Keyboard macros or custom scripts

[Solved] BASIC Runtime Error in Calc Macro

Postby khanlon » Tue Oct 24, 2017 7:55 pm

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
khanlon
 
Posts: 3
Joined: Tue Oct 24, 2017 7:36 pm

Re: BASIC Runtime Error in Calc Macro

Postby Zizi64 » Tue Oct 24, 2017 8:15 pm

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; LO4.4.7, LO5.3.7 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.3 and AOO4.1.4
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 6215
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: BASIC Runtime Error in Calc Macro

Postby Lupp » Tue Oct 24, 2017 8:41 pm

The code works for me as expected in AOO Calc 4.1.3.
On Windows 10: LibreOffice 5.4.4 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Maybe we might! (Create a powerful UFO: United Free Office)
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 1599
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: BASIC Runtime Error in Calc Macro

Postby MrProgrammer » Tue Oct 24, 2017 9:26 pm

khanlon wrote:However, when it is called from a function it receives the error below. Can someone tell me why this happens?
Are you calling this from a function in a Calc formula? If not, describe in detail how you activate your Insert_Rows subroutine.
Mr. Programmer
OpenOffice 3.2.0 Build 9483 on Mac OS X 10.9.5.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Volunteer
 
Posts: 3168
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: BASIC Runtime Error in Calc Macro

Postby khanlon » Tue Oct 24, 2017 10:30 pm

Yes, I am calling it from my user written function in a calc cell.
OpenOffice 4.1.4 / Windows 10
khanlon
 
Posts: 3
Joined: Tue Oct 24, 2017 7:36 pm

Re: BASIC Runtime Error in Calc Macro

Postby MrProgrammer » Tue Oct 24, 2017 10:43 pm

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
OpenOffice 3.2.0 Build 9483 on Mac OS X 10.9.5.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Volunteer
 
Posts: 3168
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: [Solved] BASIC Runtime Error in Calc Macro

Postby khanlon » Wed Oct 25, 2017 1:08 am

Thanks for the information / help.
OpenOffice 4.1.4 / Windows 10
khanlon
 
Posts: 3
Joined: Tue Oct 24, 2017 7:36 pm


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 5 guests