0

我正在 NeoOffice(一个 mac OO 克隆)中编写一个 Basic 宏,我想突出显示/选择宏运行时光标所在的表格中的单元格。

谷歌给了我以下相关的片段,它确实为单元格着色,但我想像使用鼠标一样选择/突出显示它。我觉得我在正确的轨道上...

Sub selectCell
    Dim the_Cursor   As Object
    Dim the_CurCell   As Object

    the_CurCell=thisComponent.currentSelection(0).cell
    the_Cursor=the_CurCell.CreateTextCursorByRange(the_CurCell.start)
    the_Cursor.GoRight(1, true) 'le curseur recouvre toute la cellule
    the_Cursor.GoLeft(1, true) 'le curseur recouvre toute la cellule

    'the_CurCell.setPropertyValue("BackColor", 16711935) ' Magenta clair / Light Magenta
End Sub

有任何想法吗?

PS:我正在运行 NeoOffice v3.3,它应该基于相同版本的 OO。

4

1 回答 1

0

从https://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=77377复制答案

Sub select_Cell_Texttable
    oTexttables = thiscomponent.texttables
    oTable1 = oTexttables.getByName("Table1")
    ocell = oTable1.getcellbyPosition(0,0)
    'ocell = oTable1.getcellbyName("A1")
    oViewCursor = ThisComponent.CurrentController.ViewCursor
    oViewCursor.gotoRange(ocell,false)
    oViewCursor.goright(1,true)
    oViewCursor.goleft(1,true)
end sub
于 2015-05-28T11:22:21.830 回答