von Karolus » Do, 25.11.2021 19:06
Hallo
dieser VBA-modus-schrott macht wirklich jegliche Verwendung von normalen Starbasic ziemlich schwierig, ich musste im Prinzip ein neues VBA -UNBEHELLIGTES dokument aufsetzen:
zuerst die python-variante:
Code: Alles auswählen
def backup(*_):
doc = XSCRIPTCONTEXT.getDocument()
sheets = doc.Sheets
kalk = sheets.Kalkulation
vorschlag = sheets.Vorschlag
ausgedruckt = sheets["ausgedruckte Vorschläge"]
data = list(zip(*vorschlag["C4:C13"].DataArray))
data = data[0]
name, street , city, _ ,datum, *_ , rezept = data
out = [[datum, name, street, city, rezept]]
ausgedruckt["A1:E1"].DataArray = out
ausgedruckt.Rows.insertByIndex(0,1)
ausgedruckt.Columns.OptimalWidth = True
vorschlag["C4:C6"].clearContents(15)
vorschlag["C13"].clearContents(15)
for addr in ("C5:C21", "A25:C41"):
kalk[addr].clearContents(15)
das funktioniert ebenso wie analog dazu:
Code: Alles auswählen
sub backup
doc = ThisComponent
sheets = doc.getSheets()
kalkulation = sheets.Kalkulation
vorschlag = sheets.getByName("Vorschlag")
ausgedruckt = sheets.getByName("ausgedruckte Vorschläge")
with vorschlag
kname = .getCellRangeByName("C4").String
strasse = .getCellRangeByName("C5").String
ort = .getCellRangeByName("C6").String
datum = .getCellRangeByName("C8").Value
rezept = .getCellRangeByName("C13").String
.getCellRangeByName("C4:C6").clearContents(15)
.getCellRangeByName("C13").clearContents(15)
end with
if kname <>"" then
out = array(array(datum, kname, strasse, ort, rezept))
with ausgedruckt
.getCellRangeByName("A1:E1").setDataArray(out)
.Rows.insertByIndex(0,1)
.Columns.OptimalWidth = True
end with
end if
with kalkulation
.getCellRangeByName("A25:C41").clearContents(15)
.getCellRangeByName("C5:C21").clearContents(15)
end with
end sub
beide Versionen sind im Dokument, momentan wird Python-variante vom Druck-button ausgeführt.
um den "druck-auftrag" hab ich mich mangels Drucker nicht gekümmert!!
Hallo
dieser VBA-modus-schrott macht wirklich jegliche Verwendung von normalen Starbasic ziemlich schwierig, ich musste im Prinzip ein neues VBA -UNBEHELLIGTES dokument aufsetzen:
zuerst die python-variante:
[code]def backup(*_):
doc = XSCRIPTCONTEXT.getDocument()
sheets = doc.Sheets
kalk = sheets.Kalkulation
vorschlag = sheets.Vorschlag
ausgedruckt = sheets["ausgedruckte Vorschläge"]
data = list(zip(*vorschlag["C4:C13"].DataArray))
data = data[0]
name, street , city, _ ,datum, *_ , rezept = data
out = [[datum, name, street, city, rezept]]
ausgedruckt["A1:E1"].DataArray = out
ausgedruckt.Rows.insertByIndex(0,1)
ausgedruckt.Columns.OptimalWidth = True
vorschlag["C4:C6"].clearContents(15)
vorschlag["C13"].clearContents(15)
for addr in ("C5:C21", "A25:C41"):
kalk[addr].clearContents(15)
[/code]
das funktioniert ebenso wie analog dazu:
[code]sub backup
doc = ThisComponent
sheets = doc.getSheets()
kalkulation = sheets.Kalkulation
vorschlag = sheets.getByName("Vorschlag")
ausgedruckt = sheets.getByName("ausgedruckte Vorschläge")
with vorschlag
kname = .getCellRangeByName("C4").String
strasse = .getCellRangeByName("C5").String
ort = .getCellRangeByName("C6").String
datum = .getCellRangeByName("C8").Value
rezept = .getCellRangeByName("C13").String
.getCellRangeByName("C4:C6").clearContents(15)
.getCellRangeByName("C13").clearContents(15)
end with
if kname <>"" then
out = array(array(datum, kname, strasse, ort, rezept))
with ausgedruckt
.getCellRangeByName("A1:E1").setDataArray(out)
.Rows.insertByIndex(0,1)
.Columns.OptimalWidth = True
end with
end if
with kalkulation
.getCellRangeByName("A25:C41").clearContents(15)
.getCellRangeByName("C5:C21").clearContents(15)
end with
end sub[/code]
[attachment=0]vorschlag_neu.ods[/attachment]
beide Versionen sind im Dokument, momentan wird Python-variante vom Druck-button ausgeführt.
um den "druck-auftrag" hab ich mich mangels Drucker nicht gekümmert!!