OOoのCalcでセルの結合にキーボード・ショートカットを割り当てる

参考:http://www.excel7.com/calc/calc_macro_shortcut.htm

ほとんど上記参考サイトに載っている通りなのだが、手順としては

  1. セルの結合・結合解除のマクロを書く
  2. 好きなキーの組み合わせにそのマクロを割り当てる

となる。

セルの縦方向の文字揃え方式を切り替えるマクロを書いてみた

Public oDocument As Object
Sub VerticalJustifyToggle()
    Dim oSelection As Object
    oDocument = ThisComponent
    oSelection = oDocument.getCurrentSelection    
    if oSelection.VertJustify = com.sun.star.table.CellVertJustify.STANDARD then
        oSelection.VertJustify = com.sun.star.table.CellVertJustify.TOP
    elseif oSelection.VertJustify = com.sun.star.table.CellVertJustify.TOP then
        oSelection.VertJustify = com.sun.star.table.CellVertJustify.CENTER
    elseif oSelection.VertJustify = com.sun.star.table.CellVertJustify.CENTER then
        oSelection.VertJustify = com.sun.star.table.CellVertJustify.BOTTOM
    elseif oSelection.VertJustify = com.sun.star.table.CellVertJustify.BOTTOM then
        oSelection.VertJustify = com.sun.star.table.CellVertJustify.STANDARD
    else
        oSelection.VertJustify = com.sun.star.table.CellVertJustify.STANDARD
    end if
End Sub