For what sheet you want to set the print ranges isn’t a question of syntax. You need to decide.
Judging from the last line of your code it should be the sheet named "Team_Results"
. If so simply delete the "Destination"
part from the non-existing variable name “oSheetDestination
”.
REM I dont Dim all the variables, and I dont use standard prefixes.
REM The standard prefix "o" was anyway used wrongly in one place.
Sub setPrintRange_For_Scramble_Team_Results()
Dim printRange(0) as new com.sun.star.table.CellRangeAddress
REM This special Dim statement is indispensable.
REM The method setPrintAreas expects a sequence of SheetCellRange structures.
REM In this case you need only one range in the sequence. It has the index 0.
mySheet = ThisComponent.Sheets.getByName (“Team_Results”)
With printRange(0)
.Sheet = mySheet.RangeAddress.Sheet
.StartColumn = 4
.StartRow = 5
.EndColumn = 12
.EndRow = 25
End With
mySheet.setPrintAreas(printRange())
End Sub
By range name your range is E6:M26. (Indices start with 1 in the sheet, but with 0 in Basic/API.)
Using it you can get your sub shorter (and easier to read):
Sub setHardCodedPrintRangeForHardCodedSheet()
Const sheetName = "Team_Results"
Const rangeName = "E6:M26"
sheet = ThisComponent.Sheets.getByName(sheetName)
range = sheet.getCellRangeByName(rangeName)
sheet.setPrintAreas(Array(range.RangeAddress))
End Sub
The Array() function is used here to create a one-element-sequence from the single RangeAddress.