Instead of splitting document into multiple documents manually, this method will introduce a VBA to split a Word document by the specified delimiter in Word. Please do as follows: 1. Note that this lesson covers Microsoft Word 2007, 2010 and 2013 for Windows, and Microsoft Word 2011 for Mac. Tell Microsoft Word not to split table rows across pages This lesson assumes you have already created a table that spans two or more pages (or will do by the time you've finished creating it). Press Alt + F11 keys together to open the Microsoft Visual Basic for Application window; 2. Click Insert > Module, and then paste below VBA code into the new opening Module window. VBA: Split Word Document into Multiple Documents by Delimiter Sub SplitNotes(delim As String, strFilename As String) Dim doc As Document Dim arrNotes Dim I As Long Dim X As Long Dim Response As Integer arrNotes = Split(ActiveDocument.Range, delim) Response = MsgBox('This will split the document into ' & UBound(arrNotes) + 1 & ' sections.Do you wish to proceed?' , 4) If Response = 7 Then Exit Sub For I = LBound(arrNotes) To UBound(arrNotes) If Trim(arrNotes(I)) ' Then X = X + 1 Set doc = Documents.Add doc.Range = arrNotes(I) doc.SaveAs ThisDocument.Path & ' ' & strFilename & Format(X, '000') doc.Close True End If Next I End Sub Sub test() 'delimiter & filename SplitNotes '///', 'Notes ' End Sub 3. Then click Run button or press F5 key to apply the VBA. In the popping out Microsoft Word document, please click the Yes button to go ahead. Note: (1) Be sure to add your delimiter as the same as '///' in the sub test to the document between each section of text you wish to separate. Also, you can change '///' to any delimiters to meet your need. (2) You can change the documents 'Notes' in the sub Test to suit your needs. (3) And the splitting documents will be saved to the same place with the original file. (4) You do not need to add delimiter to the end of the original file, if you do, there will be a blank document after splitting. Split Word document by page with VBA. Here is another VBA to help you quickly split one Word document to multiple by page in Word. Please do as follows: 1. Press Alt + F11 keys together to open the Microsoft Visual Basic for Application window; 2. Click Insert > Module, and then paste below VBA code into the new opening Module window. VBA: Split Document into Multiple Documents by Page in Word Sub SplitIntoPages() Dim docMultiple As Document Dim docSingle As Document Dim rngPage As Range Dim iCurrentPage As Integer Dim iPageCount As Integer Dim strNewFileName As String Application.ScreenUpdating = False 'Makes the code run faster and reduces screen _ flicker a bit. Set docMultiple = ActiveDocument 'Work on the active document _ (the one currently containing the Selection) Set rngPage = docMultiple.Range 'instantiate the range object iCurrentPage = 1 'get the document's page count iPageCount = docMultiple.Content.ComputeStatistics(wdStatisticPages) Do Until iCurrentPage > iPageCount If iCurrentPage = iPageCount Then rngPage.End = ActiveDocument.Range.End 'last page (there won't be a next page) Else 'Find the beginning of the next page 'Must use the Selection object. Click Enterprise > Split to enable the Split feature. In the opening Split dialog in the screen, please (1) specify the destination folder you will save the split documents into, (2) check criteria you will split by from the Split by drop down list, and (3) click the OK button. See screenshot: And now the current Word document is split by the specified criteria (Heading 1 in my case), and the destination folder opens automatically with split documents. See screenshot: Note: This fantastic Split feature also supports split one Word document by page, by page break, and by section break easily in Word. See below screenshots: Split one Word document to multiple ones by page: Split one Word document to multiple ones by page break: Split one Word document to multiple ones by section break.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2019
Categories |