【问题标题】:Adding a Comment to a cell in a macro向宏中的单元格添加注释
【发布时间】:2010-07-10 15:53:55
【问题描述】:

我想在宏的单元格中添加注释。我试过录制一个宏来做到这一点,但它什么也没做。有任何想法吗?这是录制的宏的主要内容:

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

【问题讨论】:

    标签: openoffice.org openoffice-calc


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2018-01-17
      • 1970-01-01
      • 2020-06-21
      • 2020-01-29
      • 2019-03-24
      • 1970-01-01
      • 2020-09-07
      • 2022-01-27
      • 2011-04-30
      相关资源
      最近更新 更多