LibreOffice Basic Excel VBA OffSet風の実験 [LibreOffice Calc Basic]
LibreOffice Basic Excel VBA OffSet風の実験
sub Foffset(x,y)
'ExcelVBAのOffset風
'
'xyは整数
Dim document As Object
Dim dispatcher As Object
'変数定義
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
'引数の+ー判定
'xがゼロ以上ならGoright右移動 でなければ(マイナス)ならGoleft左移動
If x>=0 Then unoGx=".uno:Goright" Else unoGx=".uno:Goleft":x=abs(x)
'yがゼロ以上ならGodown下移動 でなければ(マイナス)ならGoup上移動
If y>=0 Then unoGy=".uno:Godown" Else unoGy=".uno:Goup":y=abs(y)
'水平方向Xのプロパティ 設定
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "By" '右移動量
args1(0).Value = x '引数
args1(1).Name = "Sel" '不明
args1(1).Value = false
dispatcher.executeDispatch(document, unoGx, "", 0, args1())
'垂直方向Yのプロパティ 設定
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By" '下移動量
args3(0).Value = y '引数
args3(1).Name = "Sel"
args3(1).Value = false
dispatcher.executeDispatch(document, unoGy, "", 0, args3())
End sub
Sub test_move()
Call Foffset(-1,2)
thisComponent.currentselection.string="Offset"
End Sub
test_moveを実行でOffset風動作?
Cell B3を選択した状態で test_moveを実行
左に1,下に2 移動した
コメント 0