Thanks! Now I found it (using Xray)!

I looked for things like "delete" and "erase". "Clear" never came to my
mind... (maybe because English isn't my main language).

Now I only have to figure out how the "nContentFlags" argument works, but I
am sure I can find it now when I know what to look for.


Johnny


2007/1/27, TerryJ <[EMAIL PROTECTED]>:

Johnny Andersson wrote:
> 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
>
You could write the code in StarBasic using fewer words but what you
have is adequate.  You only need the one instruction - clearContents.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to