Thank you for your thoughtful reply. However, VB 2005 will not allow use of the "New" in that situation.
>From site http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Applying_Number_Formats: To format numeric values, an XNumberFormatsSupplier is attached to an instance of a com.sun.star.util.NumberFormatter, available at the global service manager. I cannot create an instance of com.sun.star.util.NumberFormatter; if I could, I believe the problem is solved. As I indicated, ome can easily format a number with VB 2005 using OLE Automation, as shown by the following functioning code: Imports System Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oDesk As Object Dim oDoc As Object Dim oSM As Object Dim oSheet As Object Dim oFormatter As Object Dim oNumberFormatSupplier As Object oSM = CreateObject("com.sun.star.ServiceManager") oDesk = oSM.createInstance("com.sun.star.frame.Desktop") oNumberFormatSupplier = oSM.createInstance("com.sun.star.util.XNumberFormatsSupplier") oFormatter = oSM.createInstance("com.sun.star.util.NumberFormatter") oSM = CreateObject("com.sun.star.ServiceManager") oDesk = oSM.createInstance("com.sun.star.frame.Desktop") Dim aNoArgs(-1) oDoc = oDesk.loadComponentFromURL("private:factory/scalc", "_blank", 0, aNoArgs) oSheet = oDoc.getSheets().getByIndex(0) ' Format the date cells as dates. Dim oCell As Object oSM = CreateObject("com.sun.star.ServiceManager") oCell = oSheet.getCellByPosition(0, 5) oCell.setFormula("=DATE(2009;8;10)") oCell = oSheet.getCellByPosition(0, 6) ' cell A7 oCell.setFormula("=40035") ' numerical value for 08/10/2009 in A7 oCell.NumberFormat = 5036 ' 5036 is mm/dd/yyyy oCell.CellBackColor = 36119 ' green shade oSheet.getCellByPosition(0, 8).setValue(40065) ' 09/09/2009 oSheet.getCellByPosition(0, 8).NumberFormat = 5036 ' 5036 is mm/dd/yyyy End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub End Class This works well. But I cannot format using CLI UNO. I will keep trying. Thank you. Eike Rathke wrote: > > Hi bradley36, > > Please note that I never used .Net/CLI, I'm just guessing what might be > the cause. > > On Wednesday, 2009-08-12 18:12:17 -0700, bradley36 wrote: > >> Dim oLocale As unoidl.com.sun.star.lang.Locale >> [...] >> oLocale.Language = "en" ' ********* => this is the line 80 >> referred >> to in error detail >> oLocale.Country = "US" >> oLocale.Variant = "Traditional_WIN" > >> Note that while entering code, before I execute, VB 2005 shows error >> message >> at line 80: >> oLocale is used before it has been assigned a value. A null reference >> exception could result at runtime. But line 80 does assign a value > > It assigns a value to a member of oLocale. Maybe that's the difference. > Try to allocate an instance of Locale first, e.g. > > oLocale = new unoidl.com.sun.star.lang.Locale > > or however that is done. > > A side note: you don't necessarily have to assign values to the locale, > an empty locale denotes the default locale as setup under > Tools->Options. Btw, variants currently are ignored. > > Eike > > -- > OOo/SO Calc core developer. Number formatter stricken i18n > transpositionizer. > SunSign 0x87F8D412 : 2F58 5236 DB02 F335 8304 7D6C 65C9 F9B5 87F8 D412 > OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS > Please don't send personal mail to the e...@sun.com account, which I use > for > mailing lists only and don't read from outside Sun. Use er...@sun.com > Thanks. > > > -- View this message in context: http://www.nabble.com/Cli-Uno-MS-visual-basic-2005---cannot-format-cell-programatically-tp24943858p24962147.html Sent from the openoffice - dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org