Ask Your Question

Difficulty navigating calc macro documentation [closed]

asked 2012-10-31 11:30:33 +0200

Gaffer gravatar image

My specific problem right now is "How do I write a macro to apply a name to cell?"

But the thing I really want help with is how to work out the answer to questions like these from the documentation for myself.

Of course, the first thing I did was to "record macro" whilst performing the action. That doesn't give me working code but it does at least give me a rem which suggests that ".uno:AddName" might be a clue, so I guess at some code:

fnDispatch("GoToCell", array("ToPoint", "A1")
fnDispatch("AddName", array("AddName", "foo"))

That doesn't work, so my next stop is Google. I Google various things like:

  • LibreOffice calc macro AddName
  • OpenOffice calc macro AddName
  • AddName UNO

But without turning up anything useful.

Next I go to and do some trawling. I find things like getCellRangeByName() which can use named ranges but I fail to find anything to set the range.

So, whilst an answer about how to create a named range would be very useful, what I really want to know is how could I find the functionality in the documentation for myself?

Many thanks


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-18 22:31:45.192809

2 Answers

Sort by » oldest newest most voted

answered 2012-10-31 14:23:20 +0200

JohnSUN gravatar image

Try reading a book Andrew Pitonyak.

Then download the SDK and install MRI. If MRI is properly configured, a link to the documentation required at the moment open very quickly.

edit flag offensive delete link more


I have gone off to read Andrew Pitonyak's document. I may be some time...

Gaffer gravatar imageGaffer ( 2012-10-31 17:03:01 +0200 )edit

I hope you start from chapter "6.19. Select a named range" ;-)

JohnSUN gravatar imageJohnSUN ( 2012-10-31 21:05:54 +0200 )edit

answered 2012-11-01 13:14:47 +0200

Gaffer gravatar image

Reading Andrew Pitonyak was a good answer. Right at the beginning it taught me about the debug stuff that is built in. I'm part-way through reading it cover-to cover but I also jumped ahead as you suggested and found reference to ThisComponent.NamedRange and addNewByName. A little bit of googling and now I have:

Dim oRanges    ' All named ranges.
oRanges = ThisComponent.NamedRanges

Dim oCellAddress As new
oCellAddress.Sheet = 0     'The first sheet.
oCellAddress.Column = 0    'Column A.
oCellAddress.Row = 0       'Row 1.

oRanges.addNewByName("MyName", "Sheet1.A1", oCellAddress, 0)

It helps when you realise that a range is a property of a sheet, not a cell.

The functionality is documented here:

Which I found through the main index here:

But I must be missing a clue somewhere. Why is "ThisComponent" not listed in the index?

Many thanks


edit flag offensive delete link more


JohnSUN gravatar imageJohnSUN ( 2012-11-01 14:54:09 +0200 )edit

Question Tools


Asked: 2012-10-31 11:30:33 +0200

Seen: 1,521 times

Last updated: Nov 01 '12