Privacy & CookiesThis site uses cookies. By continuing, you agree to their use. Learn more, including how to control cookies. Sử dụng đoạn code sau để tách 1 file word sau khi trộn thư ra nhiều file riêng lẻ 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. 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 có thể thay đổi địa chỉ đường dẫn nơi lưu các file được tách ra bên dưới ChangeFileOpenDirectory C:\ DocNum = DocNum + 1 ActiveDocument.SaveAs FileName:=test_ & DocNum & .doc Move the selection to the next section in the document ActiveDocument.Close savechanges:=wdDoNotSaveChanges |