sub InsertDateIntoCell 'Macro to insert current time into selected cell 'Edited version of the "InsertDateIntoCell" macro from Andrew Pitonyak's Macro document 'Andrew Pitonyak's Macro document can be found at http://www.pitonyak.org/AndrewMacro.sxw (andrew@pitonyak.org) 'Edited by Russ Phillips, 2003-08-13 (avantman42@users.sourceforge.net) Dim oDesktop As Object, oController As Object, oSelection As Object Dim doc As Object oDesktop = createUnoService("com.sun.star.frame.Desktop") oController = oDesktop.CurrentFrame.Controller doc = oController.Model If doc.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then oSelection = oController.Selection 'Set the date value oFunction = CreateUnoService("com.sun.star.sheet.FunctionAccess") oFunction.NullDate = doc.NullDate Dim aEmpty() oSelection.Value = oFunction.callFunction("NOW", aEmpty()) 'Set cell format oFormats = doc.NumberFormats dim aLocale as new com.sun.star.lang.Locale oSelection.NumberFormat = oFormats.getStandardFormat(com.sun.star.util.NumberFormat.DATE, aLocale) Else MsgBox "This macro must be run in a spreadsheet document" End If end sub