Save each page within a Word document as a separate file?

Is there any quick way to save each page within a Word document as a separate file?

Also, a way to choose the format of each new file so that it is Word 97-03 since I am using Word 2007?

 

Question Info


Last updated September 16, 2019 Views 54,377 Applies to:
Answer
Answer

You can use the following macro. For more info on installing macros, seehttp://www.gmayor.com/installing_macro.htm

Note: the line fn = "Page" + CStr(idx) + ".doc" contains the name of the files. You can change this to your liking. For example, if you wanted them stored in c:\temp, you would write something like:  fn = "c:\temp\Page" + CStr(idx) + ".doc"

=====================================

Sub SavePagesAsDoc()

    Dim orig As Document
    Dim page As Document
    Dim numPages As Integer
    Dim idx As Integer
    Dim fn As String
   
      
    ' Keep a reference to the current document.
    Set orig = ActiveDocument
   
    ' Calculate the number of pages
    numPages = ActiveDocument.Range.Information(wdActiveEndPageNumber)
   
    For idx = 1 To numPages
        ' Make sure the document is active
        orig.Activate
               
        ' Go to the page with index idx
        Selection.GoTo What:=wdGoToPage, Name:=idx
   
        ' Select the current page
        Selection.GoTo What:=wdGoToBookmark, Name:="\page"
               
        ' Copy the selection
        Selection.Copy
       
        ' Create a new document
        Set page = Documents.Add
       
        ' Activate it
        page.Activate
               
        ' Paste the selection
        Selection.Paste
       
        ' Generate the file name
        fn = "Page" + CStr(idx) + ".doc"
       
        ' Save the document as Word 97-2003
        page.SaveAs FileName:=fn, FileFormat:=wdFormatDocument, AddToRecentFiles:=False
       
        ' Close the document
        page.Close
       
    Next

End Sub

49 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.