REM ***** BASIC *****
Sub summary_odf()
' Author : Prasad Sirinayake
' Date : 19/08/2011
Dim oSheet1 as Object, oCell1 as Object, oDoc as Object
Dim oSheet as Object, oCel as Object
oDoc = ThisComponent
oSheet1 = oDoc.getSheets().getByName( "Sheet1" )
oCell1 = oSheet1.getCellRangeByName("a4")
ThisComponent.CurrentController.select(oCell1)
oAddress1 = oCell1.getCellAddress()
oCol1 = oAddress1.column
oRow1 = oAddress1.row
oSheet = oDoc.getSheets().getByName( "salaries" )
oCell = oSheet.getCellRangeByName("A6")
ThisComponent.CurrentController.select(oCell)
oAddress = oCell.getCellAddress()
oCol = oAddress.column
oRow = oAddress.row
Do While oCell.String <> ""
branch = oCell.String
if trim(oSheet.getCellByPosition(oCol+1,oRow+2).String) = "GENERAL SALES" then
gensale = trim(oSheet.getCellByPosition(oCol+1,oRow+5).Value)
endif
if trim(oSheet.getCellByPosition(oCol+2,oRow+2).String) = "LIFE SALES" then
lifesale = trim(oSheet.getCellByPosition(oCol+2,oRow+5).Value)
endif
if trim(oSheet.getCellByPosition(oCol+3,oRow+2).String) = "Others" then
others = trim(oSheet.getCellByPosition(oCol+3,oRow+5).Value)
endif
' Sheets("salaries").Select
ThisComponent.CurrentController.select("sheet1")
oCell1.String = branch
oCell1 = oSheet1.getCellByPosition(oCol1+1,oRow1)
oCell1.Value = gensale
oCell1 = oSheet1.getCellByPosition(oCol1+2,oRow1)
oCell1.Value = lifesale
oCell1 = oSheet1.getCellByPosition(oCol1+3,oRow1)
oCell1.Value = others
oRow1 = oRow1 + 1
oCell1 = oSheet1.getCellByPosition(oCol1,oRow1)
ThisComponent.CurrentController.select("salaries")
oRow = oRow + 9
oCell = oSheet.getCellByPosition(oCol,oRow)
gensale = 0
lifesale = 0
others = 0
loop
oCell1 = oSheet1.getCellRangeByName("a4")
ThisComponent.CurrentController.select(oCell1)
MsgBox "Macro Completed "
End Sub