Martin Jenniges schrieb:
Hallo Rainer,


ich habe wohl vergessen, fuer Uneingeweihte hinzuzufuegen, dass Starbasic gleich OO-Basic ist; also die Programminterne Makrosprache. Ich will in einem Script viele Zellen bez fuehrende Nullen formatieren und nicht nur per Menue Format.

Sorry, ich hatte die eigendliche Funktion vergessen anzuhängen!
Jetzt noch mal alles Komplett - geht sogar mit Copy & Paste:

*********************

Sub SetValue

Dim oDoc As Object, oSheet As Object, oCell As Object

   oDoc=ThisComponent

   oSheet=oDoc.Sheets.getByName("Tabelle1")

   oCell=oSheet.getCellByPosition(0,0) 'A1

   oCell.setValue(23658)


   oCell.NumberFormat = FindCreateNumberFormatStyle("00.000,00", odoc)

   'hier kann der unten aufgeführte Code für ein eigenes Zahlenformat rein

   'oCell.NumberFormat=2 '23658.00

   'oCell.SetString("oops")

   'oCell.setFormula("=FUNCTION()")

   'oCell.IsCellBackgroundTransparent = TRUE

   'oCell.CellBackColor = RGB(255,141,56)

End Sub


Function FindCreateNumberFormatStyle(ByVal sFormat As String,doc As Object) As Long
   Dim aLocale As New com.sun.star.lang.Locale
   Dim oFormats As Object
   Set oFormats = doc.getNumberFormats()
   Dim formatNum As Long
   formatNum = oFormats.queryKey(sFormat, aLocale, True)
   If (formatNum = -1) Then
       formatNum = oFormats.addNew(sFormat, aLocale)
       If (formatNum = -1) Then formatNum = 0
   End If
   FindCreateNumberFormatStyle = formatNum
End Function
************************

So , das ist dann auch getestet!

mfg
Volker

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@de.openoffice.org
For additional commands, e-mail: users-h...@de.openoffice.org

Antwort per Email an