von Björn89 » Sa, 03.06.2017 09:53
Dieser Code funktioniert, nur zeigt er eben 4 Nackommastellen an.
Code: Alles auswählen
sub Rechnung
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem Variableneingabe
Dim teilnahmen as Integer
teilnahmen = InputBox("Wie viele Personen haben teilgenommen?")
rem Preisberechnungen
Dim nettopreis as currency
nettopreis = teilnahmen * 4.90
Dim bruttopreis as currency
bruttopreis = nettopreis * 1.19
Dim mwsteuer as currency
mwsteuer = bruttopreis - nettopreis
'[...hier folgt nur formatierter Text...]
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "Text"
args15(0).Value = "-" + teilnahmen + " Teilnahmen am Programm" + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args15())
dim args16(0) as new com.sun.star.beans.PropertyValue
args16(0).Name = "Text"
args16(0).Value = CHR$(9) + CHR$(9) + CHR$(9) + teilnahmen + " x " + "4,90 = € " + nettopreis + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args16())
dim args17(0) as new com.sun.star.beans.PropertyValue
args17(0).Name = "Text"
args17(0).Value = CHR$(9) + CHR$(9) + CHR$(9) + CHR$(9) + "netto €" + nettopreis + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args17())
dim args18(0) as new com.sun.star.beans.PropertyValue
args18(0).Name = "Text"
args18(0).Value = CHR$(9) + CHR$(9) + CHR$(9) + CHR$(9) + "zuzügl. 19% MwSt. € " + mwsteuer + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args18())
dim args19(0) as new com.sun.star.beans.PropertyValue
args19(0).Name = "Text"
args19(0).Value = CHR$(9) + CHR$(9) + CHR$(9) + CHR$(9) + CHR$(9) + "€ " + bruttopreis + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args19())
Dieser Code funktioniert, nur zeigt er eben 4 Nackommastellen an.
[code]sub Rechnung
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem Variableneingabe
Dim teilnahmen as Integer
teilnahmen = InputBox("Wie viele Personen haben teilgenommen?")
rem Preisberechnungen
Dim nettopreis as currency
nettopreis = teilnahmen * 4.90
Dim bruttopreis as currency
bruttopreis = nettopreis * 1.19
Dim mwsteuer as currency
mwsteuer = bruttopreis - nettopreis
'[...hier folgt nur formatierter Text...]
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "Text"
args15(0).Value = "-" + teilnahmen + " Teilnahmen am Programm" + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args15())
dim args16(0) as new com.sun.star.beans.PropertyValue
args16(0).Name = "Text"
args16(0).Value = CHR$(9) + CHR$(9) + CHR$(9) + teilnahmen + " x " + "4,90 = € " + nettopreis + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args16())
dim args17(0) as new com.sun.star.beans.PropertyValue
args17(0).Name = "Text"
args17(0).Value = CHR$(9) + CHR$(9) + CHR$(9) + CHR$(9) + "netto €" + nettopreis + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args17())
dim args18(0) as new com.sun.star.beans.PropertyValue
args18(0).Name = "Text"
args18(0).Value = CHR$(9) + CHR$(9) + CHR$(9) + CHR$(9) + "zuzügl. 19% MwSt. € " + mwsteuer + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args18())
dim args19(0) as new com.sun.star.beans.PropertyValue
args19(0).Name = "Text"
args19(0).Value = CHR$(9) + CHR$(9) + CHR$(9) + CHR$(9) + CHR$(9) + "€ " + bruttopreis + CHR(10)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args19())
[/code]