2010年5月6日 星期四

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

option vbasupport 1

Sub Main

Dim cRange As new com.sun.star.table.CellRangeAddress

Set oWorkBook = ThisComponent
Set oActiveSheet = ThisComponent.CurrentController.ActiveSheet
'Sheet = thisComponent.Sheets("Sheet1")
'msgbox oWorkBook.title & " " & oActiveSheet.name

LastRowCount=range("c65536").end(xlup).row +1
'range("C" & vi)="hjflsfajfsl;ajf"

Cell = oActiveSheet.getCellRangeByName("B3")
Cell.String = "Totals"

'SumRange="B6:B" & LastRowCount
'XSumRange="range(" & SumRange & ")"
'宣告 oFunction

oFunction = CreateUnoService("com.sun.star.sheet.FunctionAccess")
'oFunction.NullDate = ThisComponent.NullDate
'oRange = oActiveSheet.getCellRangeByPosition(0,0,0,3) 'A1:A4
for i=1 to 20
oRange = oActiveSheet.getCellRangeByPosition(i,5,i,LastRowCount) 'B6:B12
oActiveSheet.getCellByPosition(i,3).value=oFunction.callFunction("SUM",Array(oRange))
next i
'
'lValue = oFunction.callFunction("SUM",Array(oRange))
'RANGE("b4")=lValue
'oActiveSheet.getCellRangeByPosition(1,6)=lValue
'oActiveSheet.getCellByPosition(1,4).value=lValue
' oSheet.getCellByPosition(0,5).setValue(lValue)
' oRange = oSheet.getCellRangeByPosition(1,0,1,3) 'B1:B4
' lValue = oFunction.callFunction("AVERAGE",Array(oRange))
' oSheet.getCellByPosition(1,5).setValue(lValue)
' oRange = oSheet.getCellRangeByName("C1:C4")
' lValue = oFunction.callFunction("MIN",Array(oRange))
' oSheet.getCellByPosition(2,5).setValue(lValue)
' oRange = oSheet.getCellRangeByName("D1:D4")
' lValue = oFunction.callFunction("MAX",Array(oRange))
'
'Cell = oActiveSheet.getCellRangeByName("B4")
'Cell.Fornula = "=SUM(B6:B31)"



End Sub

沒有留言: