我有一个有趣的问题,但在某处找不到答案。我需要打印大约 2000 封信,当然我会使用 Mail Merge 来完成。问题:我需要每一个都以 pdf 格式打印出来。我发现我必须在 Word 中使用 VBA 宏来获取单个字母(而不是在一个文档中获取全部字母),这已经有效。但我不知道如何将它们自动转换成 pdf。
有没有人有想法可以帮助我?我感谢您的帮助。
到目前为止我得到了什么(通过邮件合并制作单个文档):
Sub EinzelDatei()
Dim actpath As String, Dateiname As String
Dim fs As Object
Dim LetzterRec As Long
Const path As String = "D:\Test\"
On Error GoTo 0
Application.ScreenUpdating = False
Application.Visible = False
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdLastRecord
LetzterRec = Word.ActiveDocument.MailMerge.DataSource.ActiveRecord
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord
With ActiveDocument.MailMerge
.DataSource.ActiveRecord = wdFirstRecord
Do
If .DataSource.ActiveRecord > 0 Then
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
actpath = path & "\" 'Der aktuelle Pfad wird zusammengesetzt
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.folderexists(actpath) = False Then MkDir (actpath) 'Wenn der Pfad noch nicht existiert wird er jetzt erstellt
.FirstRecord = .ActiveRecord
.LastRecord = .ActiveRecord
Dateiname = actpath & _
.DataFields("No").Value & "-" & _
.DataFields("Surname").Value & "," & _
.DataFields("First_Name").Value & ".docx" 'Dateiname = Name, Vorname.doc
End With
.Execute Pause:=False
ActiveDocument.SaveAs FileName:=Dateiname '
ActiveDocument.Close False
End If
If .DataSource.ActiveRecord < LetzterRec Then
.DataSource.ActiveRecord = wdNextRecord
Else
Exit Do
End If
Loop
End With
MsgBox ("Erledigt")
Application.Visible = True
Application.ScreenUpdating = True
End Sub
先感谢您!!!