![]() |
|
#1
|
|||
|
|||
![]()
I need help with the macro at the bottom of this post.
This macro is supposed to take a large Word document and save each page as a new, separate file. The master file I am trying to separate is 213 pages. When I run the macro, it generates 213 new files, but the problem is that each new file it generates is the first page of the master file. In other words, all 213 new files are exactly the same. Does anyone know why this would happen? What in the macro would cause it to create 213 copies of page 1 instead of 1 copy of each of the 213 pages in the master file? Thanks in advance! --- 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(wdActiveEndPageNu mber) 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.PasteAndFormat wdFormatOriginalFormatting ' 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 |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word 2003 macro to Word 2007 to 2010 to... | maruapo | Word VBA | 0 | 06-04-2010 03:43 PM |
Inserting citations using the reference function in Microsoft Word 2007? | aeyara | Word | 0 | 09-28-2009 05:33 PM |
microsoft outlook 2007 and roaming | marko959 | Outlook | 0 | 06-03-2009 10:16 AM |
![]() |
anu | Office | 1 | 05-23-2009 10:40 AM |
Microsoft Office 2007 | riptorn | Office | 1 | 11-30-2008 06:08 PM |