Hallo Leute,
ich habe einen Serienbrief, den ich mit folgender Prozedur mit den Spalteninhalten füllen lasse.
Private Sub Rahmenvertrag_ausdrucken_Click()
Dim oApp As Object
Dim vorlage As String
Dim text As String
Dim Vorname As String
Dim Vorname1 As String
Set oApp = CreateObject(„Word.Application“)
oApp.Visible = True
vorlage = („X:\GDD\Oeffentlich\Rahmenvertrag Serienbrief.doc“)
oApp.Documents.Add Template:=vorlage
If Not IsNull(Me!Nachname) Then
oApp.Selection.Goto What:=-1, Name:=„Nachname“
text = Me!Nachname
oApp.Selection.TypeText text:=text
End If
If Not IsNull(Me!Vorname) Then
oApp.Selection.Goto What:=-1, Name:=„Vorname“
text = Me!Vorname
oApp.Selection.TypeText text:=text
End If
usw.
Ich möchte nun eine If,Then Else schleife einbauen, die zunächst die Spalte Anrede abfragt, ob Text „Herr“ darin steht und dann unter der Textmarke „Sonstige_Vereinbarungen“ den Text „-Keine-“ schreibt. Sonst Text „Alle“.
Das hab ich bisher:
If (Me!Anrede) = „Herr“ Then
oApp.Selection.Goto What:=-1, Name:=„Sonstige_Vereinbarungen“
text = „-Keine-“
Else: text = „-Alle-“
oApp.Selection.TypeText text:=text
End If
Leider funktioniert das noch nicht ganz. Hat jemand von Euch eine Idee ?
Gruß Christian