How to split & save document

D

Dileep

I have a document of 60-70 pages containing 30-40 articles,I want each
article to be saved has different files(series of file names
eg:doc(1);doc(2)..etc)
 
H

Helmut Weber

Hi,

there is nothing called "article" in Word's object model.
so Word does not know it. If you are talking of
a simple document containing sections, it goes like this:

Sub Test0031()
Dim iDoc As Integer ' number of dcouments
Dim dDc1 As Document ' active document
Dim dDc2 As Document ' new document
Dim rTmp As Range ' temporary range
Set dDc1 = ActiveDocument
For iDoc = 1 To ActiveDocument.Sections.Count
Set rTmp = ActiveDocument.Sections(iDoc).Range.FormattedText
Set dDc2 = Documents.Add(Visible:=False)
dDc2.Range.FormattedText = rTmp.FormattedText
dDc2.SaveAs "c:\test\" & Format(iDoc, "000") & ".doc"
dDc2.Close
Next
Set dDc1 = Nothing
Set dDc2 = Nothing
End Sub


But, note that
"Simple sections" excludes headers an footers, for example.
"Simple document" excludes varios kinds of document automation,
like reference fields.
The new documents would contain section breaks, which you would like
to remove, possibly. Not a problem, though, but I didn't want
to make it too complicated. And there may be many more issues,
if the doc in question is rather complex.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

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