Home > 備忘録 > libreoffice の macro(basic) > sheet 内のコントロールを操作( 97 )
コンピュータの超初心者のため、下記のコードが正しいのか分かりません。偶然にできたかもしれません。コントロールの名前は「my_ctrl_button」としています。
Sub Demo1
Dim objSheet,objForm,objCtrl As Object
Dim j As Integer
objSheet=ThisComponent.CurrentController.Activesheet
objForm=objSheet.Drawpage.Forms.GetbyIndex(0)
objCtrl=objForm.getByName("my_ctrl_button")
'ここでコントロールに対する処理をおこなう( objCtrl )
'MsgBox objCtrl.DBG_Methods
'MsgBox objCtrl.DBG_Properties
End SubSub Demo1
Dim objSheet,objForm As Object
Dim j As Integer
objSheet=ThisComponent.CurrentController.Activesheet
objForm=objSheet.Drawpage.Forms.GetbyIndex(0)
For j=0 To objForm.Count-1
If objForm.GetbyIndex(j).Name="my_ctrl_button" then
'ここでコントロールに対する処理をおこなう( objForm.GetbyIndex(j) )
'MsgBox objForm.GetbyIndex(j).DBG_Methods
'MsgBox objForm.GetbyIndex(j).DBG_Properties
End If
Next j
End Sub下記は例題です
日付コントロールの名前は「my_ctrl_button」としています。
2015年12月23日に変更する
Sub Demo2
Dim objSheet,objForm As Object
Dim j As Integer
objSheet=ThisComponent.CurrentController.Activesheet
objForm=objSheet.Drawpage.Forms.GetbyIndex(0)
For j=0 To objForm.Count-1
If objForm.GetbyIndex(j).Name="my_ctrl_button" then
Dim hiduke As New com.sun.star.util.Date
hiduke.Year=2015
hiduke.Month=12
hiduke.Day=23
objForm.GetbyIndex(j).Date=hiduke
End If
Next j
End Sub