A ver, creo que esto debe ser lo esperado por la audiencia!!!!
Listing 6.10:Formatted date in a cell.
'******************************************************************
'Author: Andrew Pitonyak
'email: [EMAIL PROTECTED]
'uses: FindCreateNumberFormatStyle
Sub InsertDateIntoCell
Dim oSelection 'The currently selected cell
Dim oFormats 'Available formats
REM Verify that this is a Calc document
If ThisComponent.SupportsService
("com.sun.star.sheet.SpreadsheetDocument") Then
oSelection = ThisComponent.CurrentSelection
Rem Set the time, date, or date and time
'oSelection.setValue(DateValue(Now())) 'Set only the date
'oSelection.setValue(TimeValue(Now())) 'Set only the time
oSelection.setValue(Now()) 'Set the date and time
Rem I could use FunctionAccess to set the date and/or time.
'Dim oFunction 'Use FunctionAccess service to call the Now function
'oFunction = CreateUnoService("com.sun.star.sheet.FunctionAccess")
'oFunction.NullDate = ThisComponent.NullDate
'oSelection.setValue(oFunction.callFunction("NOW", Array()))
Rem Set the date number format to default
oFormats = ThisComponent.NumberFormats
Dim aLocale As New com.sun.star.lang.Locale
oSelection.NumberFormat = oFormats.getStandardFormat(_
com.sun.star.util.NumberFormat.DATETIME, aLocale)
Rem Set the format to something completely different
'oSelection.NumberFormat = FindCreateNumberFormatStyle(_
' "YYYYMMDD.hhmmss", doc)
Else
MsgBox "This macro must be run in a spreadsheet document"
End If
End Sub
A shorter way to do it
Consider the following two methods (provided by Shez):
Listing 6.11:Formatted date in a cell with a shorter method.
Sub DateNow
Dim here As Object
here=ThisComponent.CurrentSelection
here.setValue(DateValue(Now))
here.NumberFormat=75
End sub
Sub TimeNow
Dim here As Object
here=ThisComponent.CurrentSelection
here.setValue(TimeValue(Now))
here.NumberFormat=41
End sub
These two methods assume a Calc document and hard code the display
format.
Si deseas te lo bajas, hay cualquier cantidad de ejemplos.
http://documentation.openoffice.org/HOW_TO/various_topics/AndrewMacro.sxw
Aqui hay posiblemente cosas que te interesen, si es que no las has visto
aun.
http://documentation.openoffice.org/HOW_TO/index.html
Bueno, espero que progreses pronto en este campo, porque de hecho
openoffice, y el uso adecuado de sus macros pueden darle un empuje
adicional a linux en lo que a desktop se refiere, aunque por el momento
no hay muchos adentrandose en ese campo.
Saludos y suerte.
FMAQ
El mar, 07-03-2006 a las 22:51 -0500, Nin Rauzer escribió:
> Ok, igual sin animo de ofender tambien ¿Has leido bien mi mail?
>
> yo no quiero que aparezca una caja con la fecha si no que inserte la
> fecha y hora en la celda activa y ya lei los manuales
> www.openoffice.org, es mas estoy seguro que encontrare la solucion
> solo queria saber si ya alguien se habia encontrado con este
> problemita
>
> 2006/3/7, Felix Manuel Arismendi Quispichuco < [EMAIL PROTECTED]>:
> Sin nada de mala onda, para algo esta la documentacion: los
> help,
> readme, install, man pages e info pages. Una leidita a la
> documentacion
> antes de postear no hace daño, o si?
>
> Estoy leyendola ahora mismo, disculpa si te molesto mi mail, ; ) no
> fue mala intencion solo que a esta hora a veces uno se bloquea,
>
> Pero bueno gracias por tomarte tu tiempo,
>
> PD: nada en mi post es ironico, por si acaso
>
>
>
>
> Saludos.
>
> FMAQ
>
>
> El mar, 07-03-2006 a las 20:56 -0500, ninrauzer escribió:
> > Disculpen el offtopic, pero ya vengo rompiendome la cabeza
> tratando de
> > hacer una macro en OO, el
> > caso es que en M$ Office es tan simple como esto:
> >
> > Sub estampar()
> > ActiveCell.FormulaR1C1 = Now()
> > End Sub
> >
> > La uso para crear una "timestamp" marca de tiempo en una
> hoja de
> > registros, pero por mas que he buscado en google, la pagina
> official de
> > oo no encuentro la manera, ya me baje un manual de macros en
> OO pero no
> > veo la forma de hacer lo que quiero, please alguna luz.?
> >
> > Saludos
> > _______________________________________________
> > Linux-plug mailing list
> > [email protected]
> > http://www.linux.org.pe/cgi-bin/mailman/listinfo/linux-plug
> >
>
>
>
> _______________________________________________
> Linux-plug mailing list
> [email protected]
> http://www.linux.org.pe/cgi-bin/mailman/listinfo/linux-plug
>
>
>
> _______________________________________________
> Linux-plug mailing list
> [email protected]
> http://www.linux.org.pe/cgi-bin/mailman/listinfo/linux-plug
_______________________________________________
Linux-plug mailing list
[email protected]
http://www.linux.org.pe/cgi-bin/mailman/listinfo/linux-plug