Adding a Comment to a cell in a macro
I want to add a Comment to a cell in 开发者_如何转开发a macro. I have tried recording a macro to do it, but it doesn't do anything. Any ideas? Here's the meat of the recorded macro:
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:DrawEditNote", "", 0, Array())
rem dispatcher.executeDispatch(document, ".uno:InsertAnnotation", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:DrawEditNote", "", 0, Array())
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "ToPoint"
args4(0).Value = "$A$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args4())
In OpenOffice it is called "Inserting Annotations"
' col, row - Zero-based
sub insertAnnotation(col, row, text)
sheet = thiscomponent.getcurrentcontroller.activesheet
cell = sheet.getCellByPosition(col, row)
sheet.Annotations.insertNew(cell.getCellAddress, text)
cell.Annotation.isVisible = True
end sub
' row, col - Zero-based
sub removeAnnotation(col, row)
sheet = thiscomponent.getcurrentcontroller.activesheet
cell = sheet.getCellByPosition(col, row)
cell.clearContents( com.sun.star.sheet.CellFlags.ANNOTATION )
end sub
insertAnnotation(2, 0, "Hello " & Now)
精彩评论