Created
March 5, 2018 16:31
-
-
Save ilkermutlu/64cf15f2a12e2dc720cc1f20a1190e96 to your computer and use it in GitHub Desktop.
Extract Pages From Word Document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' 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