1
我试图写一个快速宏,将我的邮件合并文档保存为单独的文档,然后将每个单独的文档保存为每个文档中的第一个单词。如何选择文档的第一个字
这是我到目前为止,要将文档剪下来,并将其保存为“Test_1”等,但我无法添加代码来选择第一个单词。
Sub BreakOnSection()
'Used to set criteria for moving through the document by section.
Application.Browser.Target = wdBrowseSection
'A mailmerge document ends with a section break next page.
'Subtracting one from the section count stop error message.
For i = 1 To ((ActiveDocument.Sections.Count) - 1)
'Select and copy the section text to the clipboard
ActiveDocument.Bookmarks("\Section").Range.Copy
'Create a new document to paste text from clipboard.
Documents.Add
'To save your document with the original formatting'
Selection.PasteAndFormat (wdFormatOriginalFormatting)
'Removes the break that is copied at the end of the section, if any.
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
ChangeFileOpenDirectory "H:\Output"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
ActiveDocument.Close
'Move the selection to the next section in the document
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
任何帮助将不胜感激。
感谢您的答复! 我得到的错误 - 运行时错误“5096”: (test_o.doc)的O为黑色小圆圈 调试突出了以下行 ActiveDocument.SaveAs文件名:=“TEST_”与文件名和“ .doc“ D – LinkToThis
您能分享出现错误的文档吗?我想你提到了子弹列表。 – Arul
我不会害怕,我是一名老师,它包含了大量的学生数据。 它不显示列表,它显示\t●在名称中。 – LinkToThis