0
我正在嘗試通過郵件合併併爲每個條目生成一個.txt文件。 .txt文件的標題應該與郵件合併中的一個字段相對應(嘗試使用ActiveDocument.MailMerge.Fields(1))
來獲取它)。目前,我的腳本不運行但不會產生錯誤。通過郵件合併生成txt文件標題
如果有人有任何建議,將不勝感激感謝
當前代碼:。
Option Explicit
Sub AllSectionsToSubDoc()
Dim x As Long
Dim Sections As Long
Dim Doc As Document
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set Doc = ActiveDocument
Sections = Doc.Sections.Count
For x = Sections - 1 To 1 Step -1
Doc.Sections(x).Range.Copy
Documents.Add
ActiveDocument.Range.Paste
Call ActiveDocument.SaveAs(Doc.Path & "\" & ActiveDocument.MailMerge.Fields(1) & ".txt", wdFormatText)
ActiveDocument.Close False
Next x
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub