2009/5/28 Johnny Rosenberg <[email protected]>:
> 2009/5/21 Clifton Liles <[email protected]>:
>
>> OK, I'm wrong.  I thought I saw the problem, but did not.  What we need is a
>> function that puts the results of on 'NOW()' in the cell. I do not know how
>> to do that in Calc.  It just died when I ask for the help for 'current
>> function'.  I 'll leave  this to someone who does understand Calc.  Cliff
>
> Found this short macro at some forum somewhere. Tested it and it
> works. I modified it a bit, so now it pastes the current date/time as
> a value (number). That was not a problem if the cell was pre formatted
> anyway. There is also possible to change the macro so that it also
> formats the cell automatically, but I don't believe that was asked
> for. Anyway, here's the macro, which I bound to Ctrl+space (Tools →
> Customize → Keyboard shortcuts) since Ctrl++ was already taken:
>
> REM  *****  BASIC  *****
>
> Option Explicit
>
> Sub InsertDate
>        Dim oCell As Object
>
>        oCell=ThisComponent.getCurrentController().getSelection()
>        If oCell.SupportsService("com.sun.star.sheet.SheetCell") Then '
> Selection is a single cell
>                oCell.Value=Now()
>        Else
>                MsgBox "You can't do that here"
>        EndIf
> End Sub
>

Sorry for that unfortunate line break… Hopefully this looks right:

REM  *****  BASIC  *****

Option Explicit

Sub InsertDate
        Dim oCell As Object

        oCell=ThisComponent.getCurrentController().getSelection()
        If oCell.SupportsService("com.sun.star.sheet.SheetCell") Then
                ' Selection is a single cell
                oCell.Value=Now()
        Else
                MsgBox "You can't do that here"
        EndIf
End Sub

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to