2010年1月6日 星期三

學習記錄:OpenOffice Basic (4)

REM  *****  BASIC  *****

Sub Main

  Dim oSheets       'The sheets object that contains all of the sheets
  Dim oSheet,aSheet        'Individual sheet

' ##################################################
Rem  例子一,以變數 sCount 代入,從而到達目前所在 Sheet
' ##################################################

'sCount 取得使用中 SpreadsheetDocument 的 sheet 數。
sCount=thisComponent.getSheets.getCount

' 列出所有 sheet 的名稱。日後可以在同一 SpreadsheetDocument 中轉換不同的 sheet。
For i=1 to sCount

'以變數 i 代入
aa="Sheet" & i

oSheet = thisComponent.getSheets.getByName(aa)

msgbox oSheet.Name

next i

' ##################################################
Rem  例子二,直接取得目前所在 Sheet 的名稱
' ##################################################

aSheet=ThisComponent.getCurrentController.getActiveSheet

msgbox aSheet.name

' ##################################################
Rem  例子三,取得目前所在 Sheet 的 C1 儲存格數值
' ##################################################

AAA=ThisComponent.CurrentController.ActiveSheet.getCellRangeByName("C"&"1").Value
Msgbox AAA*3

End Sub

沒有留言: