Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2004

Tip: Looking for answers? Try searching our database.

How to split & save document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dileep - 31 Dec 2004 15:11 GMT
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)
Helmut Weber - 31 Dec 2004 20:38 GMT
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/

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.