Sub
SavePrintAsPDFAndDoc()
Dim
i
As
Integer
Dim
drucken
As
Boolean
Dim
Path
As
String
Dim
sBrief
As
String
Dim
iRst
As
Integer
drucken =
True
Path = "L:\temp\Serienbriefe\Ausgabe\"
For
i = 1
To
5
With
ActiveDocument.MailMerge
.DataSource.ActiveRecord = wdFirstRecord
For
iRst = 1
To
.DataSource.RecordCount
.DataSource.ActiveRecord = iRst
.Destination = wdSendToNewDocument
.SuppressBlankLines =
True
With
.DataSource
.FirstRecord = .ActiveRecord
.LastRecord = .ActiveRecord
sBrief = Path & .DataFields(
"VBA"
).Value
End
With
.Execute Pause:=
False
If
drucken = vbYes
Then
ActiveDocument.printOut
End
If
If
i = 1
Then
ActiveDocument.SaveAs2 FileName:=sBrief &
".docx"
ActiveDocument.ExportAsFixedFormat OutputFileName:=sBrief &
".pdf"
, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=
False
, OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument
End
If
ActiveDocument.Close
False
Next
End
With
Next
End
Sub