44
Examples of Porting Visual Basic for Applications to StarBasic
Clear a range of cells on the worksheet [sheet] "MySheet". This clears everything
associated with the cell including formatting.
VBA Worksheets("MySheet").Range("B1:E5").Clear
SB
ThisComponent.Sheets.getByName("MySheet").getCellRangeByName
("B1:E5").clearContents( _
com.sun.star.sheet.CellFlags.VALUE _
+ com.sun.star.sheet.CellFlags.STRING _
+ com.sun.star.sheet.CellFlags.DATETIME _
+ com.sun.star.sheet.CellFlags.ANNOTATION _
+ com.sun.star.sheet.CellFlags.FORMULA _
+ com.sun.star.sheet.CellFlags.HARDATTR _
+ com.sun.star.sheet.CellFlags.STYLES _
+ com.sun.star.sheet.CellFlags.OBJECTS _
+ com.sun.star.sheet.CellFlags.EDITATTR)
Assign a user defined name "MyCells" to the cells B2:C3 via the Excel [Calc] user
interface
Excel
One of two methods:
1) Highlight cells B2:C3, select the tool bar options: Insert > Name > Define ,
enter name "MyCells" in pop-up window and press "Add" button.
2) Highlight cells B2:C3, then enter "MyCells" in the Name Field on the
active window.
Calc
One of two methods:
1) Highlight cells B2:C3, select the tool bar options: Insert > Names >
Define, enter name "MyCells" in pop-up window and press "Add" button.
2) Highlight cells B2:C3, press Ctrl-F3, enter name "MyCells" in pop-up
window and press "Add" button.
Assign a user defined name "MyCells" to the cells B2:C3 on "Sheet1" and the same name
to cells A1:B3 on "Sheet2" via the Excel [Calc] user interface
Excel
Select "Sheet1" and highlight cells B2:C3 then do one of the following:
1) Select the tool bar options: Insert > Name > Define , enter name
"Sheet1!MyCells" in pop-up window and press "Add" button.
2) Enter "Sheet1!MyCells" in the Name Field on the active window.
Select "Sheet2" and highlight cells A1:B3 then repeat either steps 1 or 2 from
above only this time use the name "Sheet2!MyCells".
Calc
It is not possible. Calc appears not to allow the same range name, e.g.
"MyCells", to exist on two or more worksheets [sheets].
Porting Excel/VBA to Calc/StarBasic
20