I need help badly.Someone in the Office forum suggested I post here. Thanks
I have a word document that is 357 pages. Within the document there are several file groups about 200.
For example,
File2369933 on pages 1 - 3
File9663339 on page 4
File2173993 on pages 5-9
I need to separate each file group into it's own document.
For example,
File2369933.doc
File9663339.doc
File2173993.doc
The file group names appear in the header of each page. Can someone help with a macro?
I found a Separate File by Page macro on the Microsoft website but I'm not sure how to adjust it for my needs.
The following macro copies text one page at a time and saves that text in a new document. The macro uses the pre-defined bookmark "\page" and the document's built-in property of "number of pages".
Sub BreakOnPage()
' Used to set criteria for moving through the document by page.
Application.Browser.Target = wdBrowsePage
For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of Pages")
'Select and copy the text to the clipboard.
ActiveDocument.Bookmarks("\page").Range.Copy
' Open new document to paste the content of the clipboard into.
Documents.Add
Selection.Paste
' Removes the break that is copied at the end of the page, if any.
Selection.TypeBackspace
ChangeFileOpenDirectory "C:\"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
ActiveDocument.Close
' Move the selection to the next page in the document.
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
Many thanks
I have a word document that is 357 pages. Within the document there are several file groups about 200.
For example,
File2369933 on pages 1 - 3
File9663339 on page 4
File2173993 on pages 5-9
I need to separate each file group into it's own document.
For example,
File2369933.doc
File9663339.doc
File2173993.doc
The file group names appear in the header of each page. Can someone help with a macro?
I found a Separate File by Page macro on the Microsoft website but I'm not sure how to adjust it for my needs.
The following macro copies text one page at a time and saves that text in a new document. The macro uses the pre-defined bookmark "\page" and the document's built-in property of "number of pages".
Sub BreakOnPage()
' Used to set criteria for moving through the document by page.
Application.Browser.Target = wdBrowsePage
For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of Pages")
'Select and copy the text to the clipboard.
ActiveDocument.Bookmarks("\page").Range.Copy
' Open new document to paste the content of the clipboard into.
Documents.Add
Selection.Paste
' Removes the break that is copied at the end of the page, if any.
Selection.TypeBackspace
ChangeFileOpenDirectory "C:\"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
ActiveDocument.Close
' Move the selection to the next page in the document.
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
Many thanks