Skip to content

Instantly share code, notes, and snippets.

@ilkermutlu
Created March 5, 2018 16:31
Show Gist options
  • Save ilkermutlu/64cf15f2a12e2dc720cc1f20a1190e96 to your computer and use it in GitHub Desktop.
Save ilkermutlu/64cf15f2a12e2dc720cc1f20a1190e96 to your computer and use it in GitHub Desktop.
Extract Pages From Word Document
' Found in https://www.datanumen.com/blogs/2-quick-ways-extract-individual-pages-word-document/
Sub SaveEachPageAsADoc()
Dim objNewDoc As Document
Dim objDoc As Document
Dim nPageNumber As Integer
Dim strFolder As String
Dim objFileName As Range
' Initialization
Set objDoc = ActiveDocument
strFolder = InputBox("Enter folder path here: ")
' Copy each page in the document to paste it into a new one.
For nPageNumber = 1 To ActiveDocument.ComputeStatistics(wdStatisticPages)
Application.Browser.Target = wdBrowsePage
ActiveDocument.Bookmarks("\page").Range.Select
Selection.Copy
Set objNewDoc = Documents.Add
Selection.Paste
objNewDoc.SaveAs FileName:=strFolder & "\" & "Page " & nPageNumber & ".docx"
objNewDoc.Close
Application.Browser.Next
Next nPageNumber
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment