AW: Serienbrief zusammenfügen
04.12.2014 15:00:17
fcs
Hallo Larissa,
nachfolgend ein entsprechendes Excel-Makro.
Gruß
Franz
'Erstellt unter Excel 2010 / Word 2010
'Excel-Makro
Sub SerienbriefDrucken()
' Word-Serienbrief drucken
' Das in Word aktive Dokument ( Seriendruckdokument ) wird zusammengeführt und gedruckt
If MsgBox("Seriendruckdokument in Word jetzt zusammenführen und drucken?", _
vbQuestion + vbOKCancel, "Seriendruck") = vbCancel Then Exit Sub
On Error GoTo Fehler
Dim wdApp As Object 'Variable für Word-Anwendung
Dim wdDoc As Object 'Variable für Word-Dokument
Dim strMsg As String, strTitle As String
Set wdApp = VBA.GetObject(Class:="Word.Application")
wdApp.Visible = True
Set wdDoc = wdApp.activedocument
With wdDoc.MailMerge
.Destination = 1 ' 0 = wdSendToNewDocument, 1 = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1 '1 = wdDefaultFirstRecord
.LastRecord = -16 ' -16 = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Fehler:
With Err
strMsg = "Fehler-Nr. " & .Number & vbLf & .Description
strTitle = "Makro: SerienbriefDrucken"
Select Case .Number
Case 0 'alles OK
Case 429
MsgBox strMsg & vbLf & vbLf _
& "Word ist zur Zeit nicht geöffnet", _
vbOKOnly, strTitle
Case 5535
MsgBox strMsg & vbLf & vbLf _
& "Wahrscheinlich konnte verknüpfte Datenquelle nicht geöffnet werden.", _
vbOKOnly, strTitle
Case 5852
MsgBox strMsg & vbLf & vbLf _
& "Aktives Dokument in Word ist keine Serienbriefvorlage", _
vbOKOnly, strTitle
Case Else
MsgBox strMsg, vbOKOnly, strTitle
End Select
End With
End Sub