Hi Johnny,
Alle 13:04, sabato 27 gennaio 2007, Johnny Andersson ha scritto:
> Hi!
>
> Sorry for bothering again...
>
> When I delete the contents of a cell in a macro (for a spreadsheet
> document) I just set ThisComponent.Value to 0 and .String to "" and maybe
> also Formula to "" for each cell.
> Is there a quicker way to do this, requiring only one instruction?
> I want to obtain the same result as the backspace key does to a selected
> cell range.
>
> I recorded a macro when I deleted a cell range and the result looks like
> this:
[...]
> I guess I could shorten this quite a bit and still keep the functionality,
> but isn't there an easier way?
You can also use "regular" Calc API's in this way:
REM ***** BASIC *****
Option Explicit
Sub TestClearContents
Dim oRange As Object
Dim iCellAttr As Integer
iCellAttr = _
com.sun.star.sheet.CellFlags.VALUE + _
com.sun.star.sheet.CellFlags.DATETIME + _
com.sun.star.sheet.CellFlags.STRING + _
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
oRange = ThisComponent.Sheets(0).getCellRangeByName("A1:B4")
oRange.ClearContents(iCellAttr)
End Sub
ciao
Paolo M
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]