Score:0

Problem with naming range using LibreOffice Basic in Calc

in flag

I am developing an application in Calc that uses the following code to name a range.

Dim Rname As String
Dim s As String
Dim Doc As Object
Dim Ranges As Object
Dim Sheet As Object
Ranges = Doc.NamedRanges
Sheet = Doc.Sheets.getByName("Sheet1")
Rname = "TestRange"
s = "$Sheet1.$C$11"
Ranges.addNewByName(Rname, s, Sheet.getCellByPosition(2, 10).CellAddress, 0)

The problem is that the code works fine in one computer running Ubuntu 22.10 and LibreOffice 7.4.4.2 but fails in another (the one that is supposed to run the application) with Ubuntu 22.04 LTS and LibreOffice 7.3.7.2. On the second computer I get a runtime exception "Type: com.sun.star.uno.RuntimeException Message: ./sc/source/ui/unoobj/nameuno.cxx:518."

This type of failure worries me as it raises questions to the portability of the application to other computers. Any help will be greatly appreciated. Thank you

Pilot6 avatar
cn flag
You'd better ask LO support.
Score:0
in flag

The runtime error was created because the named range had been created previously. I missed the first run of the code. It works if the name is not a duplicate.

in flag
Should link to the thread on LO, https://ask.libreoffice.org/t/problem-with-named-range-creation-using-libreoffice-basic-solved/87225.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.