Thread: [Solved] Copy a page from a document
View Single Post
 
Old 10-28-2014, 10:35 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The problem is that there are no pages in a Word document. Documents are made up of several separate overlaid elements flowed into the space between the margins. The displayed page is not a fixed entity and cannot be treated as a single item. When you select and copy the page, you are only selecting the current story range. You cannot select items that are in other layers (such as the headers and footers) at the same time.

You can get around some of it by creating the new document from the old one, but anything more radical is going to be problematic.

Put your cursor in the page and run the following macro:

Code:
Sub CopyCurrentPageToNewDoc()
Dim oNewDoc As Document
Dim oRng As Range
    On Error GoTo err_handler
    ActiveDocument.Save
    Set oRng = ActiveDocument.Bookmarks("\page").Range
    Set oNewDoc = Documents.Add(Template:=ActiveDocument.FullName)
    oNewDoc.Range.FormattedText = oRng
lbl_Exit:
    Exit Sub
err_handler:
    MsgBox "The document must be saved first!"
    Resume lbl_Exit
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote