Thats part of my problem, if i execute the code alone then it runs fine. In combination with the code before I'll get the error message.
Here's the complete code - maybe you will find something.
Thanks, NEXPERT AG
Public Sub MAIN()
Dim MacroTitle$
Dim WJ_Chan
Dim PROV$
Dim MANDANT$
Dim FNR$
Dim LNR$
Dim Owner$
Dim MWSTNr$
Dim Bankverb$
Dim Adresse1$
Dim Zeile
Dim RDat$
Dim INT_$
Dim FallNo$
Dim FallName$
Dim RVon$
Dim RBis$
Dim StdHonorar$
Dim StdTotal$
Dim PauschalHonorar$
Dim Betrag$
Dim CPOS$
Dim FixhonTotal$
Dim FixHonText$
Dim FixHonOwner$
Dim FixHonBetrag$
Dim AuslagenTyp$
Dim AuslagenTypText$
Dim AuslagenTypBetrag$
Dim AuslagenTotalBetrag$
Dim AuslagenDetText$
Dim AuslagenDetBetrag$
Dim AuslagenDetDatum$
Dim MWSTCode$
Dim ZTot$
Dim POS$
Dim Anzahl
Dim Anzahl2
Dim MWSTText$
Dim MWSTVon$
Dim MWST$
Dim MWStTotalBetrag
Dim TOTAL2$
Dim Zahlungen
Dim VorausZ$
Dim Dat$
Dim Text_$
Dim SFr$
Dim Zahlungen_$
Dim MWSTBetrag$
Dim RBetrag$
Dim MWSTinkl$
Dim MWStNetto
Dim Z1
Dim MAN$
Dim Typ$
Dim DokName$
Dim ITitel$
Dim Pfad$
Dim LenFNR
Dim LenPfad
Dim Länge
Dim dlg9 As Object
Dim DokTitel$
Dim TM$
Dim Vor$
Dim BetragHON$
Dim FalMwst$
DDETerminateAll
' ..........................
' START Einfache Auflistung
' ..........................
'On Error GoTo -1: On Error GoTo ErrorFinish
MacroTitle$ = "WinJur-Rechnung generieren"
StatusBar = "WinJur: Rechnung wird generiert..."
ActiveWindow.ActivePane.Vi
WJ_Chan = DDEInitiate(App:="WINJUR",
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
PROV$ = DDERequest(channel:=WJ_Cha
MANDANT$ = DDERequest(channel:=WJ_Cha
FNR$ = DDERequest(channel:=WJ_Cha
Ort$ = DDERequest(channel:=WJ_Cha
Sprache$ = DDERequest(channel:=WJ_Cha
LNR$ = DDERequest(channel:=WJ_Cha
WordBasic.FileSummaryInfo Keywords:="WinJur Rechnung=" + FNR$ + LNR$
FalMwst$ = DDERequest(channel:=WJ_Cha
' Festlegen der Office Version
Dim OffVer As Integer
OffVer = Left(Application.Build, 2)
'On Error GoTo -1: On Error GoTo SubFehler
' ADRESSE
GeheZuTM "Adresse"
OK$ = DDERequest(channel:=WJ_Cha
Adresse$ = DDERequest(channel:=WJ_Cha
While Adresse$ <> ""
Selection.TypeText Text:=Adresse$
Adresse$ = DDERequest(channel:=WJ_Cha
Wend
' ORT NACH FALLSTANDORT
GeheZuTM "Ort"
If Sprache$ = 0 Then
If Ort$ = 1 Then
Ortspez$ = "Basel"
End If
If Ort$ = "3" Then
Ortspez$ = "Bern"
End If
If Ort$ = "2" Then
Ortspez$ = "Küsnacht"
End If
ElseIf Sprache$ = 1 Then
If Ort$ = 1 Then
Ortspez$ = "Bâle"
End If
If Ort$ = 3 Then
Ortspez$ = "Berne"
End If
If Ort$ = 2 Then
Ortspez$ = "Küsnacht"
End If
ElseIf Sprache$ = 2 Then
If Ort$ = 1 Then
Ortspez$ = "Basilea"
End If
If Ort$ = 3 Then
Ortspez$ = "Berna"
End If
If Ort$ = 2 Then
Ortspez$ = "Küsnacht"
End If
ElseIf Sprache$ = 3 Then
If Ort$ = 1 Then
Ortspez$ = "Basel"
End If
If Ort$ = 3 Then
Ortspez$ = "Bern"
End If
If Ort$ = 2 Then
Ortspez$ = "Küsnacht"
End If
End If
Selection.TypeText Text:=Ortspez$
' DATUM Datumsformat:T.Monat Jahr
GeheZuTM "Datum"
RDat$ = DDERequest(channel:=WJ_Cha
If OffVer < "9" Then
' FUER OFFICE 97
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"ANGEBEN """ + RDat$ + """ \@ ""t. MMMM jjjj""", PreserveFormatting:=True
Else
' FUER OFFICE 2000
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"QUOTE """ + RDat$ + """ \@ ""d. MMMM yyyy""", PreserveFormatting:=True
End If
' INITIALEN
GeheZuTM "Init"
Owner_init$ = DDERequest(channel:=WJ_Cha
Selection.TypeText Text:=Owner_init$ + "/"
' OWNERINIT
Init$ = DDERequest(channel:=WJ_Cha
Selection.TypeText Text:=Init$
' RECHNUNGSNUMMER
INT_$ = DDERequest(channel:=WJ_Cha
FallNo$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Rechnungsnummer"
Selection.TypeText Text:=FallNo$ + "/R" + LNR$
' RECHNUNG PROVISORISCH
If (PROV$ = "1") Then
GeheZuTM "Provisorisch"
Selection.TypeText Text:=" Provisorisch"
GeheZuTM "Prov_Instr"
Selection.TypeText Text:="Prov_Instr"
Selection.Range.InsertAuto
End If
' FALLNAMEN
FallName$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Fallname"
Selection.TypeText Text:=FallName$
' RECHNUNGSPERIODE
RVon$ = DDERequest(channel:=WJ_Cha
RBis$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Rechnungsperiode"
' FUER OFFICE 97
If OffVer < "9" Then
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"ANGEBEN """ + RVon$ + """ \@ ""t. MMMM jjjj""", PreserveFormatting:=True
Selection.TypeText Text:=" bis "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"ANGEBEN """ + RBis$ + """ \@ ""t. MMMM jjjj""", PreserveFormatting:=True
Else
' FUER OFFICE 2000
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"Quote """ + RVon$ + """ \@ ""d. MMMM yyyy""", PreserveFormatting:=True
Selection.TypeText Text:=" bis "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"Quote """ + RBis$ + """ \@ ""d. MMMM yyyy""", PreserveFormatting:=True
End If
' HONORAR NOTARIAT
GeheZuTM "Notariat"
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_HO
POS$ = DDERequest(channel:=WJ_Cha
NotariatsZähler = 0
While POS$ <> "-1"
Datum$ = DDERequest(channel:=WJ_Cha
Std$ = DDERequest(channel:=WJ_Cha
Init$ = DDERequest(channel:=WJ_Cha
HonAnsatz$ = DDERequest(channel:=WJ_Cha
Honorar$ = DDERequest(channel:=WJ_Cha
NotMWST$ = DDERequest(channel:=WJ_Cha
If Val(Honorar$) <> 0 Then
Text_$ = DDERequest(channel:=WJ_Cha
SubTyp$ = DDERequest(channel:=WJ_Cha
If SubTyp$ = 1 Then
NotariatsZähler = NotariatsZähler + 1
Selection.TypeText Text:=Text_$
If FalMwst$ = "1" Or FalMwst$ = "10" Then
Else
If NotMWST$ = 1 Or NotMWST$ = 10 Then
Selection.TypeText Text:=" *)"
End If
End If
Selection.MoveRight Unit:=wdCell
Honorar$ = Format(Honorar$, "#,##0.00")
BetragNOT$ = Val(BetragNOT$) + Honorar$
Honorar$ = Format(Honorar$, "#,##0.00") '"#,##0.00"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="CHF" + Chr(9) + Honorar$
Selection.MoveRight Unit:=wdCell
End If
' 21.2.02 Korrektur 1
If BetragNOT$ = "" Then
BetragNOT$ = 0
End If
End If
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_HO
POS$ = DDERequest(channel:=WJ_Cha
Wend
' 21.2.02 Korrektur 2
If BetragNOT$ = "" Then
BetragNOT$ = 0
End If
Selection.Rows.Select
Selection.Rows.Delete
If NotariatsZähler = 0 Then
GeheZuTM "Notariat"
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Rows.Select
Selection.Rows.Delete
End If
' HONORAR NOTARIAT checked FS, 18.06.02
DDEExecute channel:=WJ_Chan, Command:="FORMAT_DOUBLES_O
' HONORAR TOTAL
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
StdHonorar$ = DDERequest(channel:=WJ_Cha
StdTotal$ = DDERequest(channel:=WJ_Cha
SubTyp$ = DDERequest(channel:=WJ_Cha
PauschalHonorar$ = DDERequest(channel:=WJ_Cha
BetragHON$ = DDERequest(channel:=WJ_Cha
BetragHON$ = Format(BetragHON$, "#,##0.00") '"#,##0.00"
' 21.2.02 Korrektur 3
Betrag$ = Abs(BetragHON$) - Abs(BetragNOT$)
GeheZuTM "Honorar"
If Val(Betrag$) <> 0 Then
Betrag$ = Format(Betrag$, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:="CHF" + Chr(9) + Betrag$
Else
Selection.Tables(1).Select
Selection.Rows.Delete
Selection.Delete (1)
End If
If Val(StdTotal$) <> 0 Or Val(Betrag$) <> 0 Then
' Selection.MoveRight unit:=wdCell
' Selection.TypeText Text:=Chr(9)
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Temp"
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
End If
' HONORAR TOTAL checked FS, 18.06.02
' FIXHONORARE
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_FX
CPOS$ = DDERequest(channel:=WJ_Cha
FixhonTotal$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Fixhonorar"
If Val(FixhonTotal$) <> 0 Then
While (CPOS$ <> "-1")
FixHonText$ = DDERequest(channel:=WJ_Cha
FixHonOwner$ = DDERequest(channel:=WJ_Cha
FixHonBetrag$ = DDERequest(channel:=WJ_Cha
FixMWST$ = DDERequest(channel:=WJ_Cha
Selection.TypeText Text:=FixHonText$
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If FixMWST$ = 1 Or FixMWST$ = 10 Then
Selection.TypeText Text:=" *)"
End If
End If
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
FixHonBetrag$ = Format(FixHonBetrag$, "#,##0.00") 'Betrag
Selection.TypeText Text:="CHF" + Chr(9) + FixHonBetrag$
Selection.MoveRight Unit:=wdCell
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_FX
CPOS$ = DDERequest(channel:=WJ_Cha
Wend
Selection.SelectRow
Selection.Rows.Delete
End If
If Val(FixHonBetrag$) = 0 Then
Selection.Tables(1).Select
Selection.Rows.Delete
Selection.Delete (1)
End If
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
If Val(StdTotal$) <> 0 Or Val(Betrag$) <> 0 Then
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Temp"
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
End If
' FIXHONORARE checked FS, 18.06.02
' MWST Rechnung
'ddeexecute channel:=wj_chan, command:="prep
DDEExecute channel:=WJ_Chan, Command:="PREPMWSTFOR_FIRS
POS$ = DDERequest(channel:=WJ_Cha
While (POS$ <> "-1")
mbez$ = DDERequest(channel:=WJ_Cha
DDEExecute channel:=WJ_Chan, Command:="PREPMWSTFOR_NEXT
POS$ = DDERequest(channel:=WJ_Cha
Wend
' Auslagen
DDEExecute channel:=WJ_Chan, Command:="BUILD_AUS_GROUP_
DDEExecute channel:=WJ_Chan, Command:="PREPFOR_RE_AUS_G
CPOS$ = DDERequest(channel:=WJ_Cha
Katbetrag$ = 0
GeheZuTM "Auslagen"
Selection.Font.Bold = False
Selection.Font.Underline = wdUnderlineSingle
Selection.TypeText Text:="Auslagen"
Selection.Font.Underline = wdUnderlineNone
Selection.Font.Bold = False
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
' AUSLAGEN PRO KATEGORIE SUMMIERT
Typ$ = 0
MCode2$ = 0
GeheZuTM "RestAuslagen"
sagcounter = 0 'zählt Stempel, Apostillen, Gericht
While (CPOS$ <> "-1")
AuslagenTyp$ = DDERequest(channel:=WJ_Cha
AuslagenTypText$ = DDERequest(channel:=WJ_Cha
auslagengrouptyp$ = DDERequest(channel:=WJ_Cha
AuslagenTypBetrag$ = DDERequest(channel:=WJ_Cha
MWSTCode$ = DDERequest(channel:=WJ_Cha
MWST$ = DDERequest(channel:=WJ_Cha
If AuslagenTyp$ = "0" Then 'Auslage NICHT detailliert
Typ$ = 0
ElseIf AuslagenTyp$ = "1" Then ' Auslage detailliert
Typ$ = 1
End If
' Porti, Telefon, Telefax aus CodeTab
If auslagengrouptyp$ = 2 Or auslagengrouptyp$ = 3 Or auslagengrouptyp$ = 4 Then
Typ$ = 1
AuslagenTypBetrag$ = Format(AuslagenTypBetrag$,
Katbetrag$ = Val(Katbetrag$) + Val(AuslagenTypBetrag$)
End If
' If AuslagenGroupTyp$ = 3 Then
' Typ$ = 1
' AuslagenTypBetrag$ = Format(AuslagenTypBetrag$,
' Katbetrag$ = Val(Katbetrag$) + Val(AuslagenTypBetrag$)
' End If
' If AuslagenGroupTyp$ = 4 Then
' Typ$ = 1
' AuslagenTypBetrag$ = Format(AuslagenTypBetrag$,
' Katbetrag$ = Val(Katbetrag$) + Val(AuslagenTypBetrag$)
' End If
If AuslagenTyp$ = "0" Or AuslagenTyp$ = 1 Then
If Typ$ = 0 Then
Selection.TypeText Text:=AuslagenTypText$
MCode$ = 0
' Stempel, Apostillen, Gericht aus CodeTab
If auslagengrouptyp$ = "10" Or auslagengrouptyp$ = "11" Or auslagengrouptyp$ = "16" Then
MCode$ = 1
MCode2$ = 1
End If
If MCode$ = 1 Then
If FalMwst = "1" Or FalMwst = "10" Then
Else
Selection.TypeText Text:=" *)"
End If
sagcounter = sagcounter + 1
End If
''' MCode2$ = 1
''' End If
'''End If
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
AuslagenTypBetrag$ = Format(AuslagenTypBetrag, "#,##0.00") 'Betrag
Selection.TypeText Text:="CHF" + Chr(9) + AuslagenTypBetrag$
Selection.MoveRight Unit:=wdCell
End If
End If
''' End If
DDEExecute channel:=WJ_Chan, Command:="PREPFOR_RE_AUS_G
CPOS$ = DDERequest(channel:=WJ_Cha
Wend
' AUSLAGEN MIT DETAILLIERUNG
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_AU
CPOS$ = DDERequest(channel:=WJ_Cha
mwstbefr = 0 'Standart MWST Counter für Text ohne Posiitionen mit *)
mwstausg = 0
While (CPOS$ <> "-1")
MCode$ = 0
AusTyp$ = DDERequest(channel:=WJ_Cha
AuslagenDetText$ = DDERequest(channel:=WJ_Cha
AuslagenDetBetrag$ = DDERequest(channel:=WJ_Cha
AuslagenDetDatum$ = DDERequest(channel:=WJ_Cha
AuslagenDetTextLeer$ = DDERequest(channel:=WJ_Cha
MWSTCode$ = DDERequest(channel:=WJ_Cha
If AuslagenTyp$ = "5" Or AusTyp$ = "7" Or AusTyp$ = "12" Or AusTyp$ = "13" Or AusTyp$ = "14" Then
If AuslagenDetText$ <> " " Then
Selection.TypeText Text:=AuslagenDetText$
End If
If AuslagenDetText$ = " " Then
Selection.TypeText Text:=AuslagenDetTextLeer$
End If
Else
Selection.TypeText Text:=AuslagenDetTextLeer$
End If
''' If MWSTCode$ = "0" Then
''' MCode$ = 1
''' MCode2$ = 1
''' End If
''' If MWSTCode$ = "1" Then
''' MCode$ = 1
''' MCode2$ = 1
''' End If
''' If MWSTCode$ = "10" Then
''' MCode$ = 1
''' MCode2$ = 1
''' End If
''' If FalMwst$ = 1 Or FalMwst$ = 10 Then
''''Else
''' If MCode$ = 1 Then
''' Selection.TypeText Text:=" *)"
''' MCode2$ = 1
''' End If
''' End If
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If MWSTCode$ = 1 Or MWSTCode$ = 10 Then
Selection.TypeText Text:=" *)"
End If
End If
If MWSTCode$ = 1 Then
mwstbefr = mwstbefr + 1
End If
If MWSTCode$ = 10 Then
mwstausg = mwstausg + 1
End If
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
AuslagenDetBetrag$ = Format(AuslagenDetBetrag$,
Selection.TypeText Text:="CHF" + Chr(9) + AuslagenDetBetrag$
Selection.MoveRight Unit:=wdCell
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_AU
CPOS$ = DDERequest(channel:=WJ_Cha
Wend
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
AuslagenTotalBetrag$ = DDERequest(channel:=WJ_Cha
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
With Selection.Cells
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
End With
With Selection.ParagraphFormat
.SpaceBefore = 3
End With
End With
AuslagenTotalBetrag$ = Format(AuslagenTotalBetrag
Selection.TypeText Text:="CHF" + Chr(9) + AuslagenTotalBetrag$
Selection.MoveLeft Unit:=wdCell
Selection.MoveLeft Unit:=wdCell
Selection.MoveLeft Unit:=wdCell
With Selection.Cells
With Selection.ParagraphFormat
.SpaceAfter = 3
End With
End With
' Telefon, Fax und Porto als 1. Auslage einfügen
GeheZuTM "TelFaxPorto"
If Katbetrag$ <> "0" Then
Typ$ = 1
End If
If Typ$ = 1 Then
Selection.TypeText Text:="Porti, Telefon, Telefax"
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Katbetrag$ = Format(Katbetrag$, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:="CHF" + Chr(9) + Katbetrag$
Selection.MoveRight Unit:=wdCell
End If
If Katbetrag$ = 0 Then
GeheZuTM "TelFaxPorto"
WordBasic.TableSelectRow
WordBasic.TableDeleteRow
' WordBasic.EditClear
End If
' Wenn AuslagentotalBetrag durch DDE-Befehl abgerufen werden kann, Rechnungen in den zwei While und naFr.olgende drei Zeile löschen
If Val(AuslagenTotalBetrag$) = 0 Then
WordBasic.TableSelectTable
WordBasic.TableDeleteRow
' WordBasic.EditClear
End If
' AUFWANDTOTAL MIT AUFLISTUNG MEHRWERTSTEUER
ZTot$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Zwischentot"
ZTot$ = Format(ZTot$, "#,##0.00") 'Betrag
WordBasic.Bold 0
Selection.TypeText Text:="CHF" + Chr(9) + ZTot$
WordBasic.Bold 0
DDEExecute channel:=WJ_Chan, Command:="PREPMWSTFOR_FIRS
POS$ = DDERequest(channel:=WJ_Cha
GeheZuTM "MWSTText"
Anzahl = 0
MWStTotalBetrag = 0
While (POS$ <> "-1")
If (Anzahl > 0) Then Selection.MoveRight Unit:=wdCell
MWSTText$ = DDERequest(channel:=WJ_Cha
MWSTVon$ = DDERequest(channel:=WJ_Cha
MWST$ = DDERequest(channel:=WJ_Cha
If Val(MWST$) <> 0 Then
Anzahl = Anzahl + 1
Selection.TypeText Text:=MWSTText$
WordBasic.formatfont 10
Selection.TypeText Text:=" (Nr. 326202)"
WordBasic.formatfont 12
Selection.TypeText Text:=" auf CHF "
MWSTVon$ = Format(MWSTVon$, "#,##0.00") 'Betrag
Selection.TypeText Text:=MWSTVon$
'''If MCode2$ = 1 Then
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If mwstbefr > "0" Or mwstausg > "0" Or sagcounter > 0 Then
WordBasic.formatfont 8
Selection.TypeText Text:=" ohne Pos. mit *)"
''' MCode2$ = 1
End If
End If
WordBasic.formatfont 12
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
MWST$ = Format(MWST$, "#,##0.00") 'Betrag
Selection.TypeText Text:="CHF" + Chr(9) + MWST$
MWST$ = Format(MWST$, "###0.00") 'Betrag
MWStTotalBetrag = MWStTotalBetrag + Val(MWST$) 'Wordbasic.Val
End If
DDEExecute channel:=WJ_Chan, Command:="PREPMWSTFOR_NEXT
POS$ = DDERequest(channel:=WJ_Cha
Wend
Selection.MoveRight Unit:=wdCell
WordBasic.TableSelectRow
WordBasic.TableDeleteRow
' End If
GeheZuTM "ZTotText"
Selection.Font.Underline = wdUnderlineSingle
Selection.TypeText Text:="Total Aufwand"
Selection.Font.Underline = wdUnderlineNone
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
TOTAL2$ = DDERequest(channel:=WJ_Cha
WordBasic.Bold 0
GeheZuTM "TotmitMWST"
TOTAL2$ = Format(TOTAL2$, "#,##0.00") 'Betrag
WordBasic.Bold 0
Selection.TypeText Text:="CHF" + Chr(9) + TOTAL2$
WordBasic.Bold 0
If Anzahl = 0 And Val(MWST$) = 0 Then
GeheZuTM "ZwischenTot"
WordBasic.TableSelectRow
WordBasic.TableDeleteRow
'WordBasic.EditClear
End If
' KOSTENVORSCHUSS
' fs Kostenvorschuss:
GeheZuTM "Kostenvorschuss"
Selection.TypeText Text:="Zahlungsverkehr"
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Zahlungen = 0
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_ZA
POS$ = DDERequest(channel:=WJ_Cha
Zahlungen = 0
While (POS$ <> "-1")
VorausZ$ = DDERequest(channel:=WJ_Cha
If (VorausZ$ = "1") Then
Dat$ = DDERequest(channel:=WJ_Cha
Text_$ = DDERequest(channel:=WJ_Cha
VorsMwst$ = DDERequest(channel:=WJ_Cha
SFr$ = DDERequest(channel:=WJ_Cha
Zahlungen = Zahlungen + WordBasic.Val(SFr$)
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="Kostenvorschuss vom "
Selection.TypeText Text:=Dat$
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If VorsMwst$ = 1 Or VorsMwst$ = 10 Then
Selection.TypeText Text:=" *)"
End If
End If
Selection.MoveRight Unit:=wdCell
SFr$ = Format(SFr$, "#,##0.00") 'Betrag
Selection.TypeText Text:="CHF" + Chr(9) + SFr$
Zahlungen = Zahlungen + 1
End If
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_ZA
POS$ = DDERequest(channel:=WJ_Cha
Wend
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
Zahlungen_$ = DDERequest(channel:=WJ_Cha
If Zahlungen = 0 Then
GeheZuTM "Kostenvorschuss"
WordBasic.TableSelectTable
WordBasic.TableDeleteCells
GeheZuTM "ZTotText"
WordBasic.TableSelectTable
WordBasic.TableDeleteCells
WordBasic.EditClear
WordBasic.EditClear
End If
' RECHNUNGSTOTAL
MWSTBetrag$ = DDERequest(channel:=WJ_Cha
RBetrag$ = DDERequest(channel:=WJ_Cha
MWSTinkl$ = DDERequest(channel:=WJ_Cha
MWStNetto = MWStTotalBetrag - WordBasic.Val(MWSTinkl$)
' RBetrag$ = Format(RBetrag$, "#,##0.00") '"#,##0.00"
Z1 = Val(RBetrag$)
GeheZuTM "Saldo"
' RBetrag$ = Format(RBetrag$, "#,##0.00") '"#,##0.00"
If Z1 > 0 Then
Selection.Font.Underline = wdUnderlineSingle
Selection.TypeText Text:="Total zu unseren Gunsten"
Selection.Font.Underline = wdUnderlineNone
If FalMwst$ = 1 Or FalMwst$ = 10 Then
If MWSTBetrag$ = 0 Then
If FalMwst$ = 1 Then
WordBasic.formatfont 10
Selection.TypeText Text:=" (MWSt frei)"
End If
If FalMwst = 10 Then
WordBasic.formatfont 10
Selection.TypeText Text:=" (MWSt ausgenommen)"
End If
End If
Else
If MWSTBetrag$ = 0 Then
WordBasic.formatfont 10
Selection.TypeText Text:=" (MWSt frei)"
End If
End If
Selection.MoveRight Unit:=wdCell
ZelleDoppeltUnterstreichen
If Zahlungen = 0 Then
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
With Selection.Cells
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
End With
End With
End If
' RBetrag$ = Abs(Z1)
RBetrag$ = Format(RBetrag$, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:="CHF" + Chr(9) + RBetrag$
' WordBasic.Bold 0
WordBasic.TableSelectRow
WordBasic.FormatParagraph Before:="3 pt"
WordBasic.FormatParagraph After:="3 pt"
GeheZuTM "Schluss"
If Val(MWSTinkl$) <> 0 Then
Selection.TypeText Text:="Im MWSt-Betrag von CHF "
MWStTotalBetrag = Format(MWStTotalBetrag, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:=(MWStTotalBetrag)
Selection.TypeText Text:=" sind CHF "
MWSTinkl$ = Format(MWSTinkl$, "#,##0.00")
Selection.TypeText Text:=MWSTinkl$
Selection.TypeText Text:=" MWSt auf Kostenvorschüssen enthalten, so dass sich der Netto-MWSt-Betrag dieser Rechnung auf CHF "
MWStNetto = Format(MWStNetto, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:=(MWStNetto)
Selection.TypeText Text:=" beläuft."
Selection.TypeParagraph
Selection.TypeParagraph
End If
ElseIf Z1 < 0 Then
Selection.Font.Underline = wdUnderlineSingle
Selection.TypeText Text:="Total zu Ihren Gunsten"
Selection.Font.Underline = wdUnderlineNone
Selection.MoveRight Unit:=wdCell
ZelleDoppeltUnterstreichen
RBetrag$ = Abs(RBetrag$)
RBetrag$ = Format(RBetrag$, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:="CHF" + Chr(9) + RBetrag$
WordBasic.TableSelectRow
GeheZuTM "Schluss"
If Val(MWSTinkl$) <> 0 Then
Selection.TypeText Text:="Im MWSt-Betrag von CHF "
MWStTotalBetrag = Format(MWStTotalBetrag, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:=(MWStTotalBetrag)
Selection.TypeText Text:=" sind CHF "
MWSTinkl$ = Format(MWSTinkl$, "#,##0.00")
Selection.TypeText Text:=MWSTinkl$
Selection.TypeText Text:=" MWSt auf Kostenvorschüssen enthalten, so dass sich der Netto-MWSt-Betrag dieser Rechnung auf CHF "
MWStNetto = Format(MWStNetto, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:=(MWStNetto)
Selection.TypeText Text:=" beläuft."
Selection.TypeParagraph
Selection.TypeParagraph
End If
ElseIf Z1 = 0 Then
If Vor$ = "1" Then
Selection.Font.Underline = wdUnderlineSingle
Selection.TypeText Text:="Total zu Gunsten Ihrer nächsten Rechnung"
Selection.Font.Underline = wdUnderlineNone
Selection.MoveRight Unit:=wdCell
ZelleDoppeltUnterstreichen
If RBetrag$ = 0 Then
TOTAL2$ = Format(TOTAL2$, "#,##0.00") '"####0.00"
RBetrag$ = Val(SFRTOT$) - Val(TOTAL2$)
RBetrag$ = Abs(RBetrag$)
End If
Selection.TypeText Text:="CHF" + Chr(9) + RBetrag$
WordBasic.TableSelectRow
WordBasic.EditReplace Find:="-", Replace:="", ReplaceAll:=1
GeheZuTM "Schluss"
If Val(MWSTinkl$) <> 0 Then
Selection.TypeText Text:="Im MWSt-Betrag von CHF "
MWStTotalBetrag = Format(MWStTotalBetrag, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:=(MWStTotalBetrag)
Selection.TypeText Text:=" sind CHF "
MWSTinkl$ = Format(MWSTinkl$, "#,##0.00")
Selection.TypeText Text:=MWSTinkl$
Selection.TypeText Text:=" MWSt auf Kostenvorschüssen enthalten, so dass sich der Netto-MWSt-Betrag dieser Rechnung auf CHF "
MWStNetto = Format(MWStNetto, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:=(MWStNetto)
Selection.TypeText Text:=" beläuft."
Selection.TypeParagraph
Selection.TypeParagraph
End If
Selection.TypeText Text:="Der Saldo von CHF "
RBetrag$ = Format(RBetrag$, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:=RBetrag$
Selection.HomeKey Unit:=wdLine
WordBasic.EditReplace Find:="-", Replace:="", ReplaceAll:=1
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:=" wird auf neue Rechnung vorgetragen."
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.Find.ClearFormat
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
End If
If Vor$ = "0" Then
Selection.Font.Underline = wdUnderlineSingle
Selection.TypeText Text:="Total"
Selection.Font.Underline = wdUnderlineNone
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
ZelleUnterstreichen
Selection.TypeText Text:="CHF" + Chr(9)
RBetrag$ = Abs(RBetrag$)
RBetrag$ = Format(RBetrag$, "#,##0.00") '"#,##0.00"
Selection.TypeText Text:=RBetrag$
Selection.Rows.Select
With Selection.ParagraphFormat
.SpaceAfter = 3
End With
End If
End If
' ..........................
' ENDE Einfache Auflistung
' ..........................
' ..........................
' START Detaillierte Auflistung
' ..........................
' FALLNAMEN
GeheZuTM "Rechnungsnummer2"
' FallName$ = DDERequest(channel:=WJ_Cha
FallName$ = DDERequest(channel:=WJ_Cha
Selection.TypeText Text:=FallName$
' Selection.TypeText Text:=INT_$ + "/" + FallNo$ + "/R" + LNR$
' RECHNUNG PROVISORISCH
If (PROV$ = "1") Then
GeheZuTM "Provisorisch2"
Selection.TypeText Text:=" / Provisorisch"
End If
' RECHNUNGSNUMMER
GeheZuTM "Fallname2"
FallNo$ = DDERequest(channel:=WJ_Cha
Selection.TypeText Text:=FallNo$ + "/R" + LNR$
' RECHNUNGSPERIODE
RVon$ = DDERequest(channel:=WJ_Cha
RBis$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Rechnungsperiode2"
Selection.TypeText Text:=RVon$ + " bis "
Selection.TypeText Text:=RBis$
' HONORAR DETAILLIERT
honcounter = 0
mwstfalsch = 0
StdHonorar$ = DDERequest(channel:=WJ_Cha
StdTotal$ = DDERequest(channel:=WJ_Cha
PauschalHonorar$ = DDERequest(channel:=WJ_Cha
HonorarTotalBetrag$ = DDERequest(channel:=WJ_Cha
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_HO
POS$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Honorar2"
While POS$ <> "-1"
Datum$ = DDERequest(channel:=WJ_Cha
Std$ = DDERequest(channel:=WJ_Cha
Init$ = DDERequest(channel:=WJ_Cha
HonAnsatz$ = DDERequest(channel:=WJ_Cha
Honorar$ = DDERequest(channel:=WJ_Cha
honmwstcode$ = DDERequest(channel:=WJ_Cha
HonAnsatz$ = Format(HonAnsatz$, "#,##0.00") 'Betrag
Honorar$ = Format(Honorar$, "#,##0.00") 'Betrag
If Val(Honorar$) <> 0 Then
Selection.TypeText Text:=Datum$
Selection.MoveRight Unit:=wdCell
EndWhile = 0
While EndWhile = 0
Text_$ = DDERequest(channel:=WJ_Cha
If Text_$ = "" Then
EndWhile = 1
Else
Selection.TypeText Text:=Text_$
End If
Wend
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If honmwstcode$ = "1" Or honmwstcode$ = 10 Then 'VorsMwst$ = "10" Then
Selection.TypeText Text:=" *)"
Else
honcounter = honcounter + 1
End If
End If
Selection.MoveRight Unit:=wdCell
If Val(Std$) > 0 Then
' Std$ = Format(Std$, "##0.0")
Selection.TypeText Text:=Std$
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=Init$
Else
Selection.MoveRight Unit:=wdCell
End If
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=HonAnsatz$
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="CHF" + Chr(9) + Honorar$
Selection.MoveRight Unit:=wdCell
If honmwstcode$ = MWSTCodeText$ Then
Else
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.SelectRow
' Selection.Font.Bold = True
' Selection.MoveRight unit:=wdCell
Selection.MoveDown Unit:=wdLine, Count:=1
mwstfalsch = 1
End If
End If
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_HO
POS$ = DDERequest(channel:=WJ_Cha
Wend
If Val(StdTotal$) > 0 Or Val(HonorarTotalBetrag$) > 0 Then
Selection.Font.Bold = True
Selection.TypeText Text:="Total Leistungen"
Selection.Font.Bold = False
Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend
Selection.Cells.Merge
Selection.MoveRight Unit:=wdCell
If Val(StdTotal$) > 0 Then
' StdTotal$ = Format(StdTotal$, "##0.0")
Selection.Font.Bold = True
Selection.TypeText Text:=StdTotal$
Selection.Font.Bold = False
End If
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
HonorarTotalBetrag$ = Format(HonorarTotalBetrag$
Selection.Font.Bold = True
Selection.TypeText Text:="CHF" + Chr(9) + HonorarTotalBetrag$
Selection.Font.Bold = False
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=3, Extend:=wdExtend
With Selection.Borders(wdBorder
.LineStyle = Options.DefaultBorderLineS
.LineWidth = Options.DefaultBorderLineW
End With
Selection.SelectRow
With Selection.ParagraphFormat
.SpaceBefore = 3
.SpaceAfter = 3
End With
Else
Selection.Tables(1).Select
Selection.Cells.Delete
Selection.Characters(1).Se
Selection.Delete
Selection.MoveUp
Selection.Delete Unit:=wdCharacter, Count:=1
End If
' FIXHONORARE
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_FX
CPOS$ = DDERequest(channel:=WJ_Cha
FixhonTotal$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Fixhonorar2"
If Val(FixhonTotal$) <> 0 Then
While (CPOS$ <> "-1")
FixHonText$ = DDERequest(channel:=WJ_Cha
FixHonOwner$ = DDERequest(channel:=WJ_Cha
FixHonBetrag$ = DDERequest(channel:=WJ_Cha
FixMWStCode$ = DDERequest(channel:=WJ_Cha
Selection.TypeText Text:=FixHonText$
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If FixMWStCode$ = 1 Or FixMWStCode$ = 10 Then
Selection.TypeText Text:=" *)"
End If
End If
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
FixHonBetrag$ = Format(FixHonBetrag$, "#,##0.00") 'Betrag
Selection.TypeText Text:="CHF" + Chr(9) + FixHonBetrag$
Selection.MoveRight Unit:=wdCell
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_FX
CPOS$ = DDERequest(channel:=WJ_Cha
Wend
Selection.SelectRow
Selection.Rows.Delete
ElseIf Val(FixHonBetrag$) = 0 Then
Selection.Tables(1).Select
Selection.Rows.Delete
Selection.Delete (1)
End If
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
' Auslagen
DDEExecute channel:=WJ_Chan, Command:="BUILD_AUS_GROUP_
DDEExecute channel:=WJ_Chan, Command:="PREPFOR_RE_AUS_G
CPOS$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Löschbar2"
Selection.Font.Bold = True
Selection.TypeText Text:="Barauslagen"
Selection.Font.Bold = False
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.Font.Bold = False
' AUSLAGEN PRO KATEGORIE SUMMIERT
While (CPOS$ <> "-1")
AuslagenTyp$ = DDERequest(channel:=WJ_Cha
AuslagenTypText$ = DDERequest(channel:=WJ_Cha
AuslagenTypBetrag$ = DDERequest(channel:=WJ_Cha
auslagengrouptyp$ = DDERequest(channel:=WJ_Cha
AuslagenTypBetrag$ = Format(AuslagenTypBetrag$,
If AuslagenTyp$ = "0" Then
Selection.TypeText Text:="- " + AuslagenTypText$
MCode$ = 0
' frage
If auslagengrouptyp$ = "10" Or auslagengrouptyp$ = "11" Or auslagengrouptyp$ = 16 Then
MCode$ = 1
MCode2$ = 1
End If
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If MCode$ = 1 Then
Selection.TypeText Text:=" *)"
MCode2$ = 1
End If
End If
Selection.MoveRight Unit:=wdCell
AuslagenTypBetrag$ = Format(AuslagenTypBetrag$,
Selection.TypeText Text:="CHF" + Chr(9) + AuslagenTypBetrag$
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
End If
DDEExecute channel:=WJ_Chan, Command:="PREPFOR_RE_AUS_G
CPOS$ = DDERequest(channel:=WJ_Cha
Wend
' AUSLAGEN MIT DETAILLIERUNG
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_AU
CPOS$ = DDERequest(channel:=WJ_Cha
MCode$ = 0
While (CPOS$ <> "-1")
AusTyp$ = DDERequest(channel:=WJ_Cha
AuslagenDetText$ = DDERequest(channel:=WJ_Cha
AuslagenDetBetrag$ = DDERequest(channel:=WJ_Cha
AuslagenDetDatum$ = DDERequest(channel:=WJ_Cha
AuslagenDetTextLeer$ = DDERequest(channel:=WJ_Cha
MWSTCode$ = DDERequest(channel:=WJ_Cha
If AuslagenTyp$ = "5" Or AusTyp$ = "7" Or AuslTyp$ = "12" Or AusTyp$ = "13" Or AusTyp$ = "14" Then
If AuslagenDetText$ <> " " Then
Selection.TypeText Text:=AuslagenDetText$
End If
If AuslagenDetText$ = " " Then
Selection.TypeText Text:=AuslagenDetTextLeer$
End If
Else
Selection.TypeText Text:=AuslagenDetTextLeer$
End If
If MWSTCode$ = "0" Then
MCode$ = 1
MCode2$ = 1
End If
If MWSTCode$ = "1" Then
MCode$ = 1
MCode2$ = 1
End If
If MWSTCode$ = "10" Then
MCode$ = 1
MCode2$ = 1
End If
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If MCode$ = 1 Then
If MWSTCode$ = 1 Or MWSTCode$ = 10 Then
Selection.TypeText Text:=" *)"
End If
End If
End If
Selection.MoveRight Unit:=wdCell
AuslagenDetBetrag$ = Format(AuslagenDetBetrag$,
Selection.TypeText Text:="CHF" + Chr(9) + AuslagenDetBetrag$
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_AU
CPOS$ = DDERequest(channel:=WJ_Cha
MCode$ = 0
Wend
Selection.Rows.Delete
Selection.MoveLeft Count:=3
ZelleUnterstreichen
Selection.MoveRight Unit:=wdCell
ZelleUnterstreichen
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
AuslagenTotalBetrag$ = DDERequest(channel:=WJ_Cha
AuslagenTotalBetrag$ = Format(AuslagenTotalBetrag
Selection.TypeText Text:="CHF" + Chr(9) + AuslagenTotalBetrag$
' Wenn AuslagentotalBetrag durch DDE-Befehl abgerufen werden kann, Rechnungen in den zwei While und naCHFolgende drei Zeile löschen
If Val(AuslagenTotalBetrag$) = 0 Then
WordBasic.TableSelectTable
WordBasic.TableDeleteRow
WordBasic.EditClear
End If
' AUFWANDTOTAL MIT AUFLISTUNG MEHRWERTSTEUER
ZTot$ = DDERequest(channel:=WJ_Cha
ZTot$ = Format(ZTot$, "#,##0.00") 'Betrag
GeheZuTM "Zwischentot2"
WordBasic.Bold 1
Selection.TypeText Text:="CHF" + Chr(9) + ZTot$
WordBasic.Bold 0
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
DDEExecute channel:=WJ_Chan, Command:="PREPMWSTFOR_FIRS
POS$ = DDERequest(channel:=WJ_Cha
GeheZuTM "MWSTText2"
Anzahl = 0
'''If FalMwst$ = "1" Or FalMwst$ = "10" Then
''' Selection.TypeText Text:="MWSt-frei"
'''Else
While (POS$ <> "-1")
If (Anzahl > 1) Then Selection.MoveRight Unit:=wdCell
MWSTText$ = DDERequest(channel:=WJ_Cha
MWSTVon$ = DDERequest(channel:=WJ_Cha
MWST$ = DDERequest(channel:=WJ_Cha
If Val(MWST$) <> 0 Then
Anzahl = Anzahl + 1
If (Anzahl > 1) Then Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=MWSTText$
WordBasic.formatfont 10
Selection.TypeText Text:=" (Nr. 326202)"
WordBasic.formatfont 12
Selection.TypeText Text:=" auf CHF "
MWSTVon$ = Format(MWSTVon$, "#,##0.00") 'Betrag
Selection.TypeText Text:=MWSTVon$
'''If MCode2$ = 1 Then
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If mwstbefr > 0 Or mwstausg > 0 Or sagcounter > 0 Then
WordBasic.formatfont 8
Selection.TypeText Text:=" ohne Pos. mit *)"
MCode2$ = 1
End If
End If
'End If
'End If
WordBasic.formatfont 12
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
MWST$ = Format(MWST$, "#,##0.00") 'Betrag
Selection.TypeText Text:="CHF" + Chr(9) + MWST$
' MWStTotalBetrag = MWStTotalBetrag + WordBasic.Val(MWST$) 'Deaktiviert am 9.1.02,FS
End If
DDEExecute channel:=WJ_Chan, Command:="PREPMWSTFOR_NEXT
POS$ = DDERequest(channel:=WJ_Cha
''''End If
Wend
'''End If
'''End If
Mwsttot$ = DDERequest(channel:=WJ_Cha
Mwsttot = Val(Mwsttot$)
' If Mwsttot = "0" Then
' GeheZuTM "MWSTText2"
' WordBasic.TableSelectRow
' WordBasic.TableDeleteRow
' WordBasic.EditClear
' End If
' Letzen Eintrag unterstreichen
If Mwsttot = "0" Then
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
End If
' If MCode2$ = 1 Then
' Selection.MoveLeft unit:=wdCell
' End If
If (Anzahl > 1) Then
Selection.MoveLeft Unit:=wdCell
Selection.MoveLeft Unit:=wdCharacter, Count:=1
End If
ZelleUnterstreichen
GeheZuTM "ZTotText2"
Selection.Font.Bold = True
Selection.TypeText Text:="Total inkl. MWSt"
Selection.Font.Bold = False
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
TOTAL2$ = DDERequest(channel:=WJ_Cha
WordBasic.Bold 0
GeheZuTM "TotmitMWST2"
TOTAL2$ = Format(TOTAL2$, "#,##0.00") 'Betrag
WordBasic.Bold 1
Selection.TypeText Text:="CHF" + Chr(9) + TOTAL2$
WordBasic.Bold 0
' If Anzahl = 0 And Val(MWST$) = 0 Then
' GeheZuTM "ZwischenTot2"
' WordBasic.TableSelectRow
' WordBasic.TableDeleteRow
' WordBasic.EditClear
' End If
' KOSTENVORSCHUSS
' fs Kostenvorschuss2:
GeheZuTM "Kostenvorschuss2"
WordBasic.Bold 1
Selection.TypeText Text:="Zahlungsverkehr"
WordBasic.Bold 0
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Zahlungen = 0
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_ZA
POS$ = DDERequest(channel:=WJ_Cha
Zahlungen = 0
While (POS$ <> "-1")
VorausZ$ = DDERequest(channel:=WJ_Cha
If (VorausZ$ = "1") Then
Dat$ = DDERequest(channel:=WJ_Cha
Text_$ = DDERequest(channel:=WJ_Cha
SFr$ = DDERequest(channel:=WJ_Cha
VorsMwst2$ = DDERequest(channel:=WJ_Cha
Zahlungen = Zahlungen + WordBasic.Val(SFr$)
Selection.MoveRight Unit:=wdCell
WordBasic.Bold 0
Selection.TypeText Text:="Kostenvorschuss vom "
Selection.TypeText Text:=Dat$
If FalMwst$ = 1 Or FalMwst$ = 10 Then
Else
If VorsMwst2$ = 1 Or VorsMwst2$ = 10 Then
Selection.TypeText Text:=" *)"
End If
End If
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
SFr$ = Format(SFr$, "#,##0.00") 'Betrag
Selection.TypeText Text:="CHF" + Chr(9) + SFr$
Zahlungen = Zahlungen + 1
End If
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RE_ZA
POS$ = DDERequest(channel:=WJ_Cha
Wend
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_RECHN
Zahlungen_$ = DDERequest(channel:=WJ_Cha
ZelleUnterstreichen
If Zahlungen = 0 Then
GeheZuTM "Kostenvorschuss2"
WordBasic.TableSelectTable
WordBasic.TableDeleteCells
GeheZuTM "ZTotText2"
WordBasic.TableSelectTable
WordBasic.TableDeleteCells
WordBasic.EditClear
WordBasic.EditClear
End If
' RECHNUNGSTOTAL
MWSTBetrag$ = DDERequest(channel:=WJ_Cha
RBetrag$ = DDERequest(channel:=WJ_Cha
MWSTinkl$ = DDERequest(channel:=WJ_Cha
DDEExecute channel:=WJ_Chan, Command:="FORMAT_DOUBLES_O
MWSTinkl2$ = DDERequest(channel:=WJ_Cha
DDEExecute channel:=WJ_Chan, Command:="FORMAT_DOUBLES_O
MWStNetto = MWStTotalBetrag - WordBasic.Val(MWSTinkl2$)
Z1 = Val(RBetrag$)
GeheZuTM "Saldo2"
If Z1 > 0 Then
WordBasic.Bold 1
Selection.TypeText Text:="Total zu unseren Gunsten"
WordBasic.Bold 0
If FalMwst$ = 1 Or FalMwst$ = 10 Then
If MWSTBetrag$ = 0 Then
If FalMwst$ = 1 Then
WordBasic.formatfont 10
Selection.TypeText Text:=" (MWSt frei)"
End If
If FalMwst = 10 Then
WordBasic.formatfont 10
Selection.TypeText Text:=" (MWSt ausgenommen)"
End If
End If
Else
If MWSTBetrag$ = 0 Then
WordBasic.formatfont 10
Selection.TypeText Text:=" (MWSt frei)"
End If
End If
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
ZelleDoppeltUnterstreichen
RBetrag$ = Format(RBetrag$, "#,##0.00") 'Betrag
WordBasic.Bold 1
Selection.TypeText Text:="CHF" + Chr(9) + RBetrag$
WordBasic.Bold 0
WordBasic.TableSelectRow
WordBasic.FormatParagraph After:="3 pt"
Else
WordBasic.Bold 1
Selection.TypeText Text:="Total zu Ihren Gunsten"
WordBasic.Bold 0
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
ZelleDoppeltUnterstreichen
WordBasic.Bold 1
Selection.TypeText Text:="CHF" + Chr(9) + RBetrag$
WordBasic.Bold 0
WordBasic.TableSelectRow
WordBasic.EditReplace Find:="-", Replace:="", ReplaceAll:=1
End If
' HONORARTOTALAUFSTELLUNG PRO ANWALT
DDEExecute channel:=WJ_Chan, Command:="PREPFOR_REHUSER_
POS$ = DDERequest(channel:=WJ_Cha
GeheZuTM "Mitarbeiter"
While POS$ <> "<End>"
UserName$ = DDERequest(channel:=WJ_Cha
UserInit$ = DDERequest(channel:=WJ_Cha
userstd$ = DDERequest(channel:=WJ_Cha
Userhon$ = DDERequest(channel:=WJ_Cha
UserAnsatz$ = DDERequest(channel:=WJ_Cha
' UserAuslagen$ = DDERequest(channel:=WJ_Cha
' zugehöriger DDE-Befehl fehlt noch, muss später eingebaut werden
UserTotalBetrag$ = Userhon$ + UserAuslagen$
' 21.2.02 Korrektur 4
userstd$ = Format(userstd$, "# ##0.00") '"#,##0.0"
Userhon$ = Format(Userhon$, "#,##0.00") '"#,##0.0"
UserAnsatz$ = Format(UserAnsatz$, "#,##0.00") '"#,##0.0"
UserTotalBetrag$ = Format(UserTotalBetrag$, "#,##0.00") '"#,##0.0"
Selection.TypeText Text:=UserInit$
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=userstd$
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=Userhon$
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=UserAnsatz$
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=UserAuslagen$
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=UserTotalBetrag$
Selection.MoveRight Unit:=wdCell
DDEExecute channel:=WJ_Chan, Command:="PREPFOR_REHUSER_
POS$ = DDERequest(channel:=WJ_Cha
Wend
Selection.MoveRight Unit:=wdCell
With Selection.Cells
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
End With
End With
If Val(StdTotal$) <> 0 Then Selection.TypeText Text:=StdTotal$
Selection.MoveRight Unit:=wdCell
With Selection.Cells
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
End With
End With
If Val(HonorarTotalBetrag$) <> 0 Then Selection.TypeText Text:=HonorarTotalBetrag$
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
If Val(AuslagenTotalBetrag$) <> 0 Then Selection.TypeText Text:=AuslagenTotalBetrag$
Selection.MoveRight Unit:=wdCell
With Selection.Cells
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
End With
End With
If Val(ZTot$) <> 0 Then Selection.TypeText Text:=ZTot$ 'Betrag stimmt
Selection.SelectRow
With Selection.ParagraphFormat
.SpaceBefore = 3
.SpaceAfter = 3
End With
' ORT/DATUM/INITIALEN
GeheZuTM "Ort2"
Selection.TypeText Text:=Ortspez$
GeheZuTM "Datum2"
RDat$ = DDERequest(channel:=WJ_Cha
If OffVer < "9" Then
' FUER OFFICE 97
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"ANGEBEN """ + RDat$ + """ \@ ""t. MMMM jjjj""", PreserveFormatting:=True
' FUER OFFICE 2000
Else
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"QUOTE """ + RDat$ + """ \@ ""d. MMMM yyyy""", PreserveFormatting:=True
End If
GeheZuTM "Init2"
Selection.TypeText Text:=Owner_init$ + "/" + Init
GeheZuTM "Bankverbindung"
Bank
RechnungFertig:
WordBasic.StartOfDocument
ActiveWindow.View.Type = wdPageView
Selection.HomeKey Unit:=wdStory
' ..........................
' ENDE Detaillierte Auflistung
' ..........................
' OHNE SPEICHERN
Z1 = Val(LNR$)
If Z1 = 0 Then GoTo Finish2
If (PROV$ = "1") Then GoTo Finish2
' AUTOM. DATEISPEICHERUNG
LNR$ = "000000" + LNR$
MAN$ = DDERequest(channel:=WJ_Cha
Typ$ = "R0"
DokName$ = Typ$ + Right(LNR$, 8) + ".doc"
Call SetDocProperties(DokName$)
DDEPoke channel:=WJ_Chan, Item:="SET_POKEFALLNO", Data:=FNR$
Pfad$ = DDERequest(channel:=WJ_Cha
LenFNR = Len(FNR$)
LenPfad = Len(Pfad$)
LENPfad1 = LenPfad - LenFNR
Pfad$ = Left(Pfad$, LENPfad1)
Pfad$ = Pfad$ + FNR$
DocFullName$ = Pfad$ + Application.PathSeparator + DokName$
If Dir(Pfad$, vbDirectory) = "" Then
MkDir Pfad$
End If
ActiveDocument.SaveAs FileName:=DocFullName$
' Defining Logtext of Invoice in WinJur
If IsDate(RVon$) = True Then
RVon$ = Format(RVon$, "d.m.yyyy")
End If
If IsDate(RBis$) = True Then
RBis$ = Format(RBis$, "d.m.yyyy")
End If
Str_InvLogtext = "RG: " & RVon$ & " - " & RBis$
DDEPoke channel:=WJ_Chan, Item:="SET_POKEMANDANT", Data:=MAN$
DDEPoke channel:=WJ_Chan, Item:="SET_POKELOGNO", Data:=LNR$
DDEPoke channel:=WJ_Chan, Item:="LOG_DOKUMENTNAME", Data:=ActiveDocument.Name
DDEPoke channel:=WJ_Chan, Item:="LOG_PATHNAME", Data:=ActiveDocument.Path
DDEPoke channel:=WJ_Chan, Item:="LOG_LOGTEXT", Data:=Str_InvLogtext
GoTo Cont
SubFehler:
CheckError Err.Number, TM$
Cont:
ErrorFinish:
Finish2:
DDEExecute channel:=WJ_Chan, Command:="DESTROY_RECHNUNG
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_NOTHI
DDETerminate channel:=WJ_Chan
StatusBar = "WinJur Ok"
GoTo Exit_
Finish1:
DDEExecute channel:=WJ_Chan, Command:="DESTROY_RECHNUNG
DDEExecute channel:=WJ_Chan, Command:="PREPLOGFOR_NOTHI
DDETerminate channel:=WJ_Chan
StatusBar = "WinJur Macro not Ok"
GoTo Exit_
Exit_:
End Sub
Private Sub GeheZuTM(TextMarke$)
Dim TM$
TM$ = TextMarke$
If WordBasic.ExistingBookmark
Selection.GoTo What:=wdGoToBookmark, Name:=TM$
Else
WordBasic.MsgBox "Textmarke: " + TM$, "Fehlende Textmarke"
CheckError 1005, TM$
End If
End Sub
Private Sub CheckError(Err_, TM$)
Dim Continue
'-----------------------
Select Case Err_
Case 1005
WordBasic.MsgBox "Textmarke: " + TM$, "Fehlende Textmarke"
Case Else
WordBasic.MsgBox "WordBasic Error: " + Str(Err_), "WJDCC/WinWord Fehler"
End Select
Err_ = 0
Continue = 0
DDETerminateAll
End Sub
Public Static Sub Bank()
Load UserForm1
UserForm1.Show
End Sub
Public Sub UserForm_Initialize()
Load UserForm1
UserForm1.Show
End Sub
Public Sub doku()
GeheZuTM "Bankverbindung"
Unload UserForm1
End Sub
Public Sub divers()
Dim Prompt
Dim Bankverbindung
Prompt = "Bitte geben Sie hier ihre Bankverbindung ein."
Bankverbindung = InputBox(Prompt)
' MsgBox (Bankverbindung), , "Eingabe"
GeheZuTM "Bankverbindung"
Selection.ParagraphFormat.
Selection.Font.Bold = False
Selection.Font.Underline = wdUnderlineSingle
Selection.TypeText Text:="Bankverbindung:"
Selection.Font.Underline = wdUnderlineNone
Selection.TypeText Text:=Chr(11)
Selection.TypeText Bankverbindung
End Sub
Sub SetDocProperties(DokName$)
Dim dp As Object
Set dp = ActiveDocument.BuiltInDocu
dp("Title") = DokName$
dp("KeyWords") = "WinJur"
End Sub
Public Sub ZelleUnterstreichen()
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
With Selection.Font
.Underline = wdUnderlineSingle
.UnderlineColor = wdColorAutomatic
.Color = wdColorAutomatic
End With
End Sub
Public Sub ZelleDoppeltUnterstreichen
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
With Selection.Font
.Underline = wdUnderlineDouble
.UnderlineColor = wdColorAutomatic
.Color = wdColorAutomatic
End With
End Sub
Main Topics
Browse All Topics





by: plauwaerPosted on 2003-08-11 at 16:47:54ID: 9126263
If i execute you code. I don't get your problem.
Width = wdLineWidth050pt Style = wdLineStyleSingle
I suggest the following:
With Selection.Cells
.Borders(wdBorderTop).Line
.Borders(wdBorderTop).Line
With Selection.ParagraphFormat
.SpaceBefore = 3
End With
End With
End Sub
- If this does not solve you problem than may be the problem comes from code that is executed before this code is executed.
Send more code. So i can replicate the error.
Patrick