Macro Help: Splitting each page so that each page is an individual word document

C

cardioblack

Hi,

I am in need of help on building a macro that will take multi page
document and splitting each page so that each page would be an
individual word document. Any help would be great. Thanks!
 
D

Doug Robbins - Word MVP

Sub splitter()

'

' splitter Macro

' Macro created 16-08-98 by Doug Robbins to save each page of a document

' as a separate file with the name Page#.DOC

'

Dim Counter As Long, Source As Document, Target As Document

Set Source = ActiveDocument

Selection.HomeKey Unit:=wdStory

Pages = Source.BuiltInDocumentProperties(wdPropertyPages)

Counter = 0

While Counter < Pages

Counter = Counter + 1

DocName = "Page" & Format(Counter)

Source.Bookmarks("\Page").Range.Cut

Set Target = Documents.Add

Target.Range.Paste

Target.SaveAs FileName:=DocName

Target.Close

Wend

End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

cardioblack

Thank you so much for responding so quickly!

I tried running the macro on a word document that I have.

An error generates : Run-Time Error '5690'
The Selection is marked as deleted text

When I click debug - Source.Bookmarks("\Page").Range.Cut

is highlighted.

If you need any more information, I'd be happy to help. I'm going to
try it on another document for now to see if it works on that one
instead.
 
C

cardioblack

I tried it on another document. It seemed to have worked however the
files saved to a specific location.

My screen would show a document under name doc1.doc , doc2.doc ,
doc3.doc appear and disappear from the screen but I don't find it
anywhere in my hard drive.
 
D

Doug Robbins - Word MVP

They will have been saved in the default documents folder with names like
Page1, Page2, Page3, etc.

However if you want to save them to a specific place, replace the following
line of code

DocName = "Page" & Format(Counter)

with

DocName = "[Drive]:\[Folder]\Page" & Format(Counter)

where you replace [Drive] with the drive letter and [Folder] with the folder
name

For example

DocName = "c:\splitdocuments\Page" & Format(Counter)



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top