2010-07-10 53 views
3

我想添加一个评论到宏中的单元格。我曾试着录制一个宏来做它,但它什么也没做。有任何想法吗?这里是录制宏的肉:添加评论到宏中的单元格

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()) 

回答

2

在OpenOffice的它被称为“插入批注”

' 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)