使用MS Word 2010我想要一個Mailmerge與一個宏一起運行,將每個記錄以PDF格式保存爲一個單獨的文件,並使用其中一個字段作爲文件名。這將節省我的時間。使用MS Word Mailmerge Macro丟失格式
我得到的問題是格式完全丟失,好像它只是複製文本並將其粘貼到新文檔中。有沒有什麼辦法可以保護格式化,因爲沒有它,這是非常無果的...
在此先感謝。
Sub splitter()
Dim i As Integer
Dim Source As Document
Dim Target As Document
Dim Letter As Range
Dim oField As Field
Dim FileNum As String
Set Source = ActiveDocument
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdLastRecord
For i = 1 To ActiveDocument.MailMerge.DataSource.ActiveRecord
ActiveDocument.MailMerge.DataSource.ActiveRecord = i
Set Letter = Source.Range
For Each oField In Letter.Fields
If oField.Type = wdFieldMergeField Then
If InStr(oField.Code.Text, "INV_ID") > 0 Then
FileNum = oField.Result
End If
End If
Next oField
Set Target = Documents.Add
Target.Range = Letter
Target.SaveAs2 "C:\BACS\INVOICING\INVOICES\Word Export\" & FileNum, 17
Target.Close
Next i
End Sub
哇哇哇。你絕對是超級明星!格拉西亞斯 – user2032006