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:

REM  *****  BASIC  *****
sub DeleteContentsOfCellRange
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$5:$B$6"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
end sub

I guess I could shorten this quite a bit and still keep the functionality,
but isn't there an easier way?

Johnny

Reply via email to