"Break" document

D

D

Hi:


I have an *.rtf document conataining reports for restaurants; most of the
time is one store per page, (sometimes more than one page); the store number
is part of the 'header'.

What would be the code, if there is any, to search by store, make a page
break when the report for one store ends and save it as an individaul report,
like 123.rtf, 457, rtf; so at the end of the day I have 10 separate reports.

Thanks,

Dan
 
W

Word Heretic

G'day "D" <[email protected]>,

Depends on how that info is represented in the header. Is it a
StyleRef field or a hard-coded number?

Press Alt+F9 to reveal field codes.

If its hardcoded you would iterate like this

Dim Sect as Section
Dim Target as Document

For each Sect in ActiveDocument.Sections
'Sect.Range holds your report here
Sect.Range.Copy
Set Target = Documents.Add
Target.Content.Paste
Next
Set Sect = Nothing
Set Target = Nothing


If it's a STYLREF field in the header then we have to search for the
next instance of the style to get our range.


Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


D reckoned:
 
D

D

Hi:

Thanks!

It is hard coded; actually this document is an MS Access report exported; I
ran the code but all what it does is creating another document, the same like
the first one..

Thanks again,

Dan
 

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