Ask Your Question

Macro cannot add annotation to same sheet

asked 2016-03-07 02:43:59 +0200

j.beguin gravatar image

updated 2016-03-07 12:29:21 +0200

Alex Kemp gravatar image


I have a problem which I don't know if it's a bug or if I just made some error in the code.

Function AddAnnotation(annotation as String, s as integer, r as integer, c as integer)
    Sheets = ThisComponent.Sheets
    Sheet = Sheets.getByIndex(s-1)
    Annotations = Sheet.getAnnotations()
    Cell = Sheet.getCellByPosition(c, r)
    CellAddr = Cell.CellAddress
    Annotations.insertNew(CellAddr, annotation)
    Cell.Annotation.isVisible = True
End Function

This macro add an annotation to a cell specified by s, r and c. It work perfectly fine if the targeted cell is on another sheet than the one where the macro was called from but if you call it to the same one then it doesn't do anything. For example: If I call =AddAnnotation("TEST"; 2; 1; 1) from a cell on the first sheet it'll work and add an annotation to the second sheet cell "B2" but if i call the same code from a cell on the second sheet it won't work.

I'm on Windows 7 and this problem exist at least on OpenOffice 4.1.2 and LibreOffice

Any suggestions?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2016-03-07 09:50:15 +0200

karolus gravatar image


You are calling the Function as "User-defined-Function" out from a cell in Calc!?

Calc locks the entire sheet meanwhile Formula-calculations.

edit flag offensive delete link more


Yes, i can´t call it differently because i want to be able to change parameters on the fly using information from cells. Is there a way to circumvent this locking?

Edit: I've checked if the Document, sheet or cell were locked using isActionLocked() or protected with isProtected()but no.

j.beguin gravatar imagej.beguin ( 2016-03-07 12:34:23 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-03-07 02:43:59 +0200

Seen: 127 times

Last updated: Mar 07 '16