Splitting output pages.

S

SW

Hi Everyone,

We currently run Crystal Reports as our core reporting product. The files
that it generates can be in a variety of formats such as RTF or MS Word
format.

Is there a way using VB Code to split the pages into seperate files? Crystal
reports does not in itself offer this functionality, so perhaps we can use
Word itself?

Any ideas most appreciated.
 
D

Doug Robbins - Word MVP

Hi SW,

The following will do it:

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
'
Selection.HomeKey Unit:=wdStory
Pages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
Counter = 0
While Counter < Pages
Counter = Counter + 1
DocName = "Page" & Format(Counter)
ActiveDocument.Bookmarks("\Page").Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs FileName:=DocName, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Wend

End Sub

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
F

Francis Dion

Doug's answer works greate if you don't mind calling the Word
application from your program. If this is an issue for you, you might
want to investigate XpertDoc, a Word document generator that gives you
more control than Crystal over the structure of the document and the
navigation through your data sets.

You can download it from www.xpertdoc.com

Regards,
 

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