Date: prev next · Thread: first prev next last
2018 Archives by date, by thread · List index


Hallo Andreas,

wenn das Makro

Sub InsertRow
Dim oD as Object ' [object] Dokument
Dim oT as Object ' [object] Tabellenblatt
Dim oZ as Object ' [object] Zeile
Dim A as Long ' Anzahl
Dim Y as Long ' Y-Index (1.Zeile: Y=0)
oD = ThisComponent
oT = oD.Sheets(0)
oZ = oT.getRows
Y = 1
A = 1
oZ.insertByIndex(Y,A)
End Sub

die Zeile an der von Dir gewünschten Stelle einfügt, dann muss man nur noch die Zellen dieser Zeile entsprechend formatieren. Das kann man auch mit dem Makro gleich mit machen. Anbei eine beispielsweise Erweiterung obigen Makros mit Formatierung für die ersten 3 Zellen der eingefügten Zeile mit "Text", "Datum TT.MM.JJJJ" und "Ganzzahl mit einer führenden Null":

Sub InsertRow
Dim oD as Object ' [object] Dokument
Dim oT as Object ' [object] Tabellenblatt
Dim oZ as Object ' [object] Zeile
Dim A  as Long   ' Anzahl
Dim Y  as Long   ' Y-Index (1.Zeile: Y=0)
oD = ThisComponent
oT = oD.Sheets(0)
oZ = oT.getRows
Y = 1
A = 1
oZ.insertByIndex(Y,A) ' Zeile einfügen
oT.getCellByPosition(0,Y).NumberFormat = 100 ' Format Zelle "A2": "Text"
oT.getCellByPosition(1,Y).NumberFormat = 36 ' Format Zelle "B2": "Datum TT.MM.JJJJ" oT.getCellByPosition(2,Y).NumberFormat = 1 ' Format Zelle "C2": "Ganzzahl mit einer führenden Null"
End Sub

Zur Überprüfung der durchgeführten Zell-Formatierungen: Entsprechende Zelle markieren und [Format]>[Zellen]. Dann bekommt man das aktuelle Format der Zelle von "CALC" angezeigt.

Weitere/andere "NumberFormat"-Angaben kann man mit diesem Makro selbst herausfinden:

Sub CellNumberFormat
Dim oD as Object ' [object] Dokument
Dim oT as Object ' [object] Tabellenblatt
Dim ZFN as Integer ' Zell Format Nummer
oD = ThisComponent
oT = oD.Sheets(0)
ZFN = oS.getCellByPosition(0,0).NumberFormat ' aktuelles Zell-Format auslesen
MsgBox("ZellFormatNummer: " & ZFN) ' aktuelles Zell-Format anzeigen
End Sub

Dazu die Zelle "A1" wie gewünscht manuell formatieren und anschließend das Makro starten. Die entsprechende "ZellFormatNummer" für die "NumberFormat"-Anweisung wird dann via "MsgBox" angezeigt.

Gefunden bei: www.dannenhoefer.de => "7.1.26 Wie kann man das Zellenformat einstellen ?"

Gruß
Hans-Werner :-))

--
Liste abmelden mit E-Mail an: users+unsubscribe@de.libreoffice.org
Probleme? https://de.libreoffice.org/hilfe-kontakt/mailing-listen/abmeldung-liste/
Tipps zu Listenmails: https://wiki.documentfoundation.org/Netiquette/de
Listenarchiv: https://listarchives.libreoffice.org/de/users/
Datenschutzerklärung: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.