I love to create spreadsheets and often offer to help my co-workers with automating their scalc files for them. I have a lot of fun writing StarBasic macros. With a little work the StarBasic macros can be modified to work in other office programs.
Two functions that I add to almost every spreadsheet are GetCell and GetDataCell to make it easy and fast to read and change the cell contents.
Function GetDataCell(SheetName As String, DataName As String, Row) As com.sun.star.table.XCell AllSheets = ThisComponent.Sheets() FindSheet = AllSheets.GetByName(SheetName) For ALoopCounter = 0 to 1000 Step 1 TheCell = FindSheet.GetCellByPosition(ALoopCounter,0) If TheCell.String = DataName then TheCell = FindSheet.GetCellByPosition(ALoopCounter,Row) Exit for End if If TheCell.String = "" then MsgBox("Could not find DataField = "+DataName) Stop End if Next ALoopCounter GetDataCell = TheCell End Function Function GetCell(SheetName As String, Column, Row) As com.sun.star.table.XCell AllSheets = ThisComponent.Sheets() FindSheet = AllSheets.GetByName(SheetName) TheCell = FindSheet.GetCellByPosition(Column,Row) GetCell = TheCell End Function
No comments:
Post a Comment