0

如何在 Libreoffice 的计算中选择当前行?使用宏。

我想要达到的效果是:如果当前行是奇数行,将当前行背景色改为蓝色。

If currentAddress.Row mod 2 = 1 Then
    dim document   as object
    dim dispatcher as object
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

    dim args1(0) as new com.sun.star.beans.PropertyValue
    args1(0).Name = "ToPoint"
    args1(0).Value = "$A$3:$H$3"

    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

    dim args2(0) as new com.sun.star.beans.PropertyValue
    args2(0).Name = "BackgroundColor"
    args2(0).Value = 17798

    dispatcher.executeDispatch(document, ".uno:BackgroundColor", "", 0, args2())
End If

args1(0).Value = "$A$3:$H$3" ,

“$A$3:$H$3”。如何将其表示为带有变量的范围?谢谢!

4

2 回答 2

0

我想要达到的效果是:如果当前行是奇数行,将当前行背景色改为蓝色。

全选,格式>条件格式>条件...>条件1,公式为,

ISODD(ROW())  

新样式... > 背景,选择蓝色、OKOK

替代方案:自动格式化

于 2019-01-20T16:55:11.483 回答
0

选择一个单元格并运行此代码

sub main
    Doc=thiscomponent
    Sheet=Doc.currentcontroller.activesheet
    ActiveCell = Doc.CurrentSelection 
    r = ActiveCell.CellAddress.Row
    if r mod 2 = 1 Then
        Sheet.getRows().getByIndex(r).cellBackColor = RGB(173,216,230) 
    end if   
end sub
于 2019-01-20T18:54:03.910 回答