LibreOffice Calc トレースを全て削除するマクロ [LibreOffice Calc Basic]
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearArrows", "", 0, Array())
end sub
LibreOffice Calc Basic NASに保存するマクロの実験 [LibreOffice Calc Basic]
' ルーターの簡易NAS に日付を先頭に付加して保存
'例 test.ods 20170421test.ods
'ファイル名取得
fileName=ThisComponent.title
'Print fileName
'日付から / を削除 置換 2017/04/21 20170421
st=Replace(date,"/","")
'Print st
'NASに保存
saveURL="smb://aterm@192.168.0.1/Toshiba-1/Calc/" & st & fileName
'Print saveURL
ThisComponent.StoreAsURL(saveURL ,Array())
msgbox saveURL & chr(10) & " 保存完了"
End Sub
LibreOffice Calc Basic 表示画面の拡大、縮小をするマクロの実験 [LibreOffice Calc Basic]
LbreOffice Calc Basic 表示画面の拡大、縮小をするマクロの実験
OS LinuxMint18Cinnamon64bit
LibreOffice5.2
Sub zoom_in
'Calcのみ 表示拡大
'現在のzoom値
zoom_value= ThisComponent.CurrentController.zoomValue
'Print zoom_value
'zoomvalueセット
ThisComponent.CurrentController.zoomValue=zoom_value+10
End Sub
Sub zoom_out
'Calcのみ 表示縮小
'現在のzoom値
zoom_value= ThisComponent.CurrentController.zoomValue
'Print zoomvalue
'zoomvalueセット
ThisComponent.CurrentController.zoomValue=zoom_value-10
End Sub
Sub zoom_100
'zoom値を標準にする
'zoomvalueセット
ThisComponent.CurrentController.zoomValue=100
End Sub
LibreOffice Calc Basic 選択範囲を小数点以下2桁にするマクロの実験 [LibreOffice Calc Basic]
LibreOffice Calc Basic 選択範囲を小数点以下2桁にするマクロの実験
B3,B7に12345.678と入力後、B7を選択してマクロを実行。
12345.68と表示されるのは四捨五入の為。
Sub syousu2()
'小数点以下2桁
ThisComponent.CurrentController.Selection.NumberFormat=2
End Sub
数字 NumberFormat 0 = 1 0.00 = 2 #,##0 = 3 #,##0.00 = 4 #,###.00 = 5
LibreOffice Calc Basic FileExists 関数でファイル(フォルダ)の存在を調べる [LibreOffice Calc Basic]
LibreOffice Calc Basic FileExists 関数でファイル(フォルダ)の存在を調べる。
書式
FileExists ( Name )
結果
Boolean
True:対象フォルダ,ファイルは存在します
False:対象フォルダ,ファイルは存在しません
Sub FileExists_test()
'NASにファイルがあるかを調べる
Dim fileURL As string
fileURL = "smb://192.168.0.1/toshiba-1/Calc/So-netBlog統合管理.ods"
If FileExists(fileURL) then
MsgBox fileURL & " は存在します"
else
MsgBox fileURL & " は存在しません"
End If
End Sub