Clear cell contents Macro help
Posted: Mon Feb 11, 2008 10:22 pm
Hi, am converting a sheet to Calc from Excel and require to clear range of cells prior to filling with new data. (some cells must contain no data).
Have cut and pasted from various sites but each time I get:-
"Basic runtime Error" An Eception occurred $(ARG1).
EXAMPLE1 from Andrew Pitonyak
EXAMPLE 2 from Star Office site
Am I missing an OOo lib or something similar. Any help appreciated.
Have cut and pasted from various sites but each time I get:-
"Basic runtime Error" An Eception occurred $(ARG1).
EXAMPLE1 from Andrew Pitonyak
Code: Select all
Sub ClearDefinedRange
Dim Doc As Object
Dim Sheet As Object
Dim CellRange As Object
Dim Flags As Long
Doc = StarDesktop.CurrentComponent
Sheet = Doc.Sheets(0)
CellRange = Sheet.getCellRangeByName("B71:E83")
Flags = com.sun.star.sheet.CellFlags.STRING + _ <<< ERROR POINTS TO THIS LINE
com.sun.star.sheet.CellFlags.HARDATTR
CellRange.clearContents(Flags)
End SubCode: Select all
Sub ClearCellContents
Dim nFlags As Long
Dim oRange As New com.sun.star.table.CellRangeAddress
oRange = oSheet.getCellRangeByName( "B71:E83" )
nFlags = com.sun.star.sheet.CellFlags.STRING + _ <<< ERROR POINTS TO THIS LINE
com.sun.star.sheet.CellFlags.STYLES
oRange.clearContents( nFlags )
End Sub