My little macro is called by event of “selection changed”.
It sets annotations visible = true, when there cell is selected and sets all other annotations visible = false.
Sub SetAnotationVisible()
On Error GoTo ErrorHandling
doc = ThisComponent
sheet = doc.currentController.activeSheet
currentSelection = doc.CurrentSelection
If Not currentSelection.supportsService("com.sun.star.sheet.SheetCell") Then
Exit Sub
End If
SetAllAnnotationsNotVisible(sheet)
currentSelection.Annotation.IsVisible = True
Exit Sub
ErrorHandling:
StandardErrorMessage()
End Sub
'_________________________________________________________________________________
Sub SetAllAnnotationsNotVisible(sheet As Object)
Dim allAnnotations As Object : allAnnotations = sheet.Annotations
Dim index As Long
For index = 0 To allAnnotations.count - 1
allAnnotations(index).IsVisible = False
Next index
End Sub
As far as you don’t touch the annotations it runs very well. But if you select an annotation window and edit the text, it runs unstable.
If you enlarge the window and click in a free area within the window, Calc often crashes.
I have worked out, that calc notices cell selections behind the annotation window. Maybe this gets an conflict of edit text and visibility of annotation at same time!?!
I would like to block the macro if an annotation is in edit mode. But how can I query this?