Word-Serienbrief mit VBA: 1000 Dokumente in Minuten
Lesezeit: 10 Min. | Word & Dokumente
Standard-Serienbrief in Word ist umständlich und langsam. Mit VBA automatisieren Sie den Prozess: 1000 personalisierte Dokumente in 2 Minuten generieren, als PDF speichern und per Outlook versenden. Dieser Guide zeigt den kompletten Workflow.
Standard-Serienbrief vs. VBA-Automatisierung
Word-Serienbrief (manuell):
- ❌ Kompliziertes Setup
- ❌ Langsam bei 1000+ Empfängern
- ❌ Schwer zu debuggen
- ❌ Keine Kontrolle über PDF-Namen
VBA-Automatisierung:
- ✅ Volle Kontrolle
- ✅ Super schnell
- ✅ Beliebige Platzhalter
- ✅ PDF-Export + E-Mail in einem Schritt
Word-Referenz in Excel einbinden
- VBA-Editor (Alt + F11)
- Extras → Verweise
- Häkchen bei: Microsoft Word XX.0 Object Library
- OK
Vorlage öffnen und Platzhalter ersetzen
Word-Vorlage vorbereiten
Erstellen Sie Word-Dokument mit Platzhaltern:
Sehr geehrte/r {{NAME}},
vielen Dank für Ihre Bestellung vom {{DATUM}}.
Ihre Bestellnummer: {{BESTELLNR}}
Betrag: {{BETRAG}} EUR
Mit freundlichen Grüßen
vielen Dank für Ihre Bestellung vom {{DATUM}}.
Ihre Bestellnummer: {{BESTELLNR}}
Betrag: {{BETRAG}} EUR
Mit freundlichen Grüßen
Speichern als: C:\Vorlagen\Serienbrief.docx
VBA-Code zum Ersetzen
Sub SerienbriefErstellen()
Dim wordApp As New Word.Application
Dim wordDoc As Word.Document
' Vorlage öffnen
Set wordDoc = wordApp.Documents.Open("C:\Vorlagen\Serienbrief.docx")
' Platzhalter ersetzen
With wordDoc.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "{{NAME}}"
.Replacement.Text = "Max Mustermann"
.Execute Replace:=wdReplaceAll
.Text = "{{DATUM}}"
.Replacement.Text = Format(Date, "DD.MM.YYYY")
.Execute Replace:=wdReplaceAll
End With
' Speichern
wordDoc.SaveAs2 "C:\Output\Brief_Mustermann.docx"
wordDoc.Close
wordApp.Quit
End Sub
Dim wordApp As New Word.Application
Dim wordDoc As Word.Document
' Vorlage öffnen
Set wordDoc = wordApp.Documents.Open("C:\Vorlagen\Serienbrief.docx")
' Platzhalter ersetzen
With wordDoc.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "{{NAME}}"
.Replacement.Text = "Max Mustermann"
.Execute Replace:=wdReplaceAll
.Text = "{{DATUM}}"
.Replacement.Text = Format(Date, "DD.MM.YYYY")
.Execute Replace:=wdReplaceAll
End With
' Speichern
wordDoc.SaveAs2 "C:\Output\Brief_Mustermann.docx"
wordDoc.Close
wordApp.Quit
End Sub
Daten aus Excel-Tabelle lesen
Excel-Struktur:
Spalte A: Name
Spalte B: Bestellnummer
Spalte C: Datum
Spalte D: Betrag
Spalte E: E-Mail
Spalte B: Bestellnummer
Spalte C: Datum
Spalte D: Betrag
Spalte E: E-Mail
Dokumente generieren (Loop)
Sub SerienbriefMassenproduktion()
Dim wordApp As New Word.Application
Dim wordDoc As Word.Document
Dim i As Long
Dim lastRow As Long
Dim vorlage As String
Dim ausgabePfad As String
vorlage = "C:\Vorlagen\Serienbrief.docx"
ausgabePfad = "C:\Output\"
wordApp.Visible = False ' Im Hintergrund
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
For i = 2 To lastRow
' Vorlage öffnen
Set wordDoc = wordApp.Documents.Open(vorlage)
' Platzhalter ersetzen
With wordDoc.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "{{NAME}}"
.Replacement.Text = Cells(i, 1).Value
.Execute Replace:=wdReplaceAll
.Text = "{{BESTELLNR}}"
.Replacement.Text = Cells(i, 2).Value
.Execute Replace:=wdReplaceAll
.Text = "{{DATUM}}"
.Replacement.Text = Format(Cells(i, 3).Value, "DD.MM.YYYY")
.Execute Replace:=wdReplaceAll
.Text = "{{BETRAG}}"
.Replacement.Text = Format(Cells(i, 4).Value, "#,##0.00")
.Execute Replace:=wdReplaceAll
End With
' Speichern als DOCX
wordDoc.SaveAs2 ausgabePfad & "Brief_" & Cells(i, 1).Value & ".docx"
wordDoc.Close
' Status in Excel
Cells(i, 6).Value = "Erstellt " & Now
Next i
wordApp.Quit
Application.ScreenUpdating = True
MsgBox lastRow - 1 & " Dokumente erstellt!", vbInformation
End Sub
Dim wordApp As New Word.Application
Dim wordDoc As Word.Document
Dim i As Long
Dim lastRow As Long
Dim vorlage As String
Dim ausgabePfad As String
vorlage = "C:\Vorlagen\Serienbrief.docx"
ausgabePfad = "C:\Output\"
wordApp.Visible = False ' Im Hintergrund
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
For i = 2 To lastRow
' Vorlage öffnen
Set wordDoc = wordApp.Documents.Open(vorlage)
' Platzhalter ersetzen
With wordDoc.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "{{NAME}}"
.Replacement.Text = Cells(i, 1).Value
.Execute Replace:=wdReplaceAll
.Text = "{{BESTELLNR}}"
.Replacement.Text = Cells(i, 2).Value
.Execute Replace:=wdReplaceAll
.Text = "{{DATUM}}"
.Replacement.Text = Format(Cells(i, 3).Value, "DD.MM.YYYY")
.Execute Replace:=wdReplaceAll
.Text = "{{BETRAG}}"
.Replacement.Text = Format(Cells(i, 4).Value, "#,##0.00")
.Execute Replace:=wdReplaceAll
End With
' Speichern als DOCX
wordDoc.SaveAs2 ausgabePfad & "Brief_" & Cells(i, 1).Value & ".docx"
wordDoc.Close
' Status in Excel
Cells(i, 6).Value = "Erstellt " & Now
Next i
wordApp.Quit
Application.ScreenUpdating = True
MsgBox lastRow - 1 & " Dokumente erstellt!", vbInformation
End Sub
Als PDF speichern
' Statt wordDoc.SaveAs2 für DOCX:
wordDoc.ExportAsFixedFormat _
OutputFileName:=ausgabePfad & "Brief_" & Cells(i, 1).Value & ".pdf", _
ExportFormat:=wdExportFormatPDF
wordDoc.Close SaveChanges:=False
wordDoc.ExportAsFixedFormat _
OutputFileName:=ausgabePfad & "Brief_" & Cells(i, 1).Value & ".pdf", _
ExportFormat:=wdExportFormatPDF
wordDoc.Close SaveChanges:=False
Automatisches Versenden per Outlook
Sub SerienbriefMitEmail()
Dim wordApp As New Word.Application
Dim wordDoc As Word.Document
Dim outlookApp As New Outlook.Application
Dim mailItem As Outlook.MailItem
Dim i As Long, lastRow As Long
Dim pdfPfad As String
wordApp.Visible = False
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow
' Dokument erstellen
Set wordDoc = wordApp.Documents.Open("C:\Vorlagen\Serienbrief.docx")
' Platzhalter ersetzen (wie oben)
' ...
' Als PDF exportieren
pdfPfad = "C:\Output\Brief_" & Cells(i, 1).Value & ".pdf"
wordDoc.ExportAsFixedFormat OutputFileName:=pdfPfad, ExportFormat:=wdExportFormatPDF
wordDoc.Close SaveChanges:=False
' E-Mail versenden
Set mailItem = outlookApp.CreateItem(olMailItem)
With mailItem
.To = Cells(i, 5).Value ' E-Mail aus Spalte E
.Subject = "Ihre Bestellung " & Cells(i, 2).Value
.Body = "Sehr geehrte/r " & Cells(i, 1).Value & "," & vbCrLf & _
"anbei Ihre Rechnung."
.Attachments.Add pdfPfad
.Send
End With
' Status
Cells(i, 6).Value = "Versendet " & Now
Next i
wordApp.Quit
MsgBox "Fertig!", vbInformation
End Sub
Dim wordApp As New Word.Application
Dim wordDoc As Word.Document
Dim outlookApp As New Outlook.Application
Dim mailItem As Outlook.MailItem
Dim i As Long, lastRow As Long
Dim pdfPfad As String
wordApp.Visible = False
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow
' Dokument erstellen
Set wordDoc = wordApp.Documents.Open("C:\Vorlagen\Serienbrief.docx")
' Platzhalter ersetzen (wie oben)
' ...
' Als PDF exportieren
pdfPfad = "C:\Output\Brief_" & Cells(i, 1).Value & ".pdf"
wordDoc.ExportAsFixedFormat OutputFileName:=pdfPfad, ExportFormat:=wdExportFormatPDF
wordDoc.Close SaveChanges:=False
' E-Mail versenden
Set mailItem = outlookApp.CreateItem(olMailItem)
With mailItem
.To = Cells(i, 5).Value ' E-Mail aus Spalte E
.Subject = "Ihre Bestellung " & Cells(i, 2).Value
.Body = "Sehr geehrte/r " & Cells(i, 1).Value & "," & vbCrLf & _
"anbei Ihre Rechnung."
.Attachments.Add pdfPfad
.Send
End With
' Status
Cells(i, 6).Value = "Versendet " & Now
Next i
wordApp.Quit
MsgBox "Fertig!", vbInformation
End Sub
Performance: 1000 Briefe in 2 Minuten
Optimierungen:
- ✅
wordApp.Visible = False– Kein Fenster - ✅
Application.ScreenUpdating = Falsein Excel - ✅ Keine
wordApp.Activate - ✅ Vorlage einmal öffnen, mehrfach nutzen
Vollständiges Code-Template
Sub SerienbriefKomplett()
On Error GoTo ErrorHandler
Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Dim i As Long
Dim lastRow As Long
Dim startTime As Double
startTime = Timer
Set wordApp = New Word.Application
wordApp.Visible = False
Application.ScreenUpdating = False
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow
Set wordDoc = wordApp.Documents.Open("C:\Vorlagen\Serienbrief.docx")
With wordDoc.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "{{NAME}}"
.Replacement.Text = Cells(i, 1).Value
.Execute Replace:=wdReplaceAll
End With
wordDoc.ExportAsFixedFormat "C:\Output\" & i & ".pdf", wdExportFormatPDF
wordDoc.Close False
Next i
Cleanup:
If Not wordApp Is Nothing Then wordApp.Quit
Application.ScreenUpdating = True
MsgBox "Fertig in " & Format(Timer - startTime, "0.0") & " Sek!", vbInformation
Exit Sub
ErrorHandler:
MsgBox "Fehler: " & Err.Description, vbCritical
Resume Cleanup
End Sub
On Error GoTo ErrorHandler
Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Dim i As Long
Dim lastRow As Long
Dim startTime As Double
startTime = Timer
Set wordApp = New Word.Application
wordApp.Visible = False
Application.ScreenUpdating = False
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow
Set wordDoc = wordApp.Documents.Open("C:\Vorlagen\Serienbrief.docx")
With wordDoc.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "{{NAME}}"
.Replacement.Text = Cells(i, 1).Value
.Execute Replace:=wdReplaceAll
End With
wordDoc.ExportAsFixedFormat "C:\Output\" & i & ".pdf", wdExportFormatPDF
wordDoc.Close False
Next i
Cleanup:
If Not wordApp Is Nothing Then wordApp.Quit
Application.ScreenUpdating = True
MsgBox "Fertig in " & Format(Timer - startTime, "0.0") & " Sek!", vbInformation
Exit Sub
ErrorHandler:
MsgBox "Fehler: " & Err.Description, vbCritical
Resume Cleanup
End Sub
Fazit
VBA-Serienbrief ist 100x schneller als manuell:
- ✅ 1000 Dokumente in 2 Minuten
- ✅ Automatischer PDF-Export
- ✅ E-Mail-Versand integriert
- ✅ Volle Kontrolle über Platzhalter