Imported Access report, need to save as separate docs

H

Heidi M

I have a report I've created in Access because I needed 2 levels of
grouping - I have a 17-day event where customers could visit several
exhibits each day, so I need to group first by customer, then by
exhibit. The details per exhibit list the dates, number of tickets
ordered per guest, and price per date.

I have sent this to Word because I need to be able to save each
person's report as a separate file, so I can continue on towards a
email merge with attachemnts. The problem is that I can only find
macros that split a general Word document based on a number of pages,
and the file name is a generic "Page 1". The number of pages will
vary from guest to guest and I need to name the file based on the
customer's account number, so I'm looking for one of two things:

Either A) a way to create this multi-level grouping as a mail merge
directly in Word, so I can run the macro I already have to name the
file based on a field contained in the merge, or B) Another way to
export my report from Access so I can separate the file another way.

Any help will be greatly appreciated! (I am somewhat familiar with VB
but not an experienced programmer).
 
D

Doug Robbins - Word MVP

The following macro is designed to split a document at each section break,
which is what divides a mailmerge document.

If you were to insert something at the bottom of your access report design
that could be used for an Edit>Replace in Word, then you could use that
facility to replace that something with a section break and then use this
macro to split the document

Sub splitter()
' splitter Macro
' Macro created by Doug Robbins to save each letter created by a mailmerge
' as a separate file, retaining the header and footer information.
Dim i As Long, Source As Document, Target As Document, Letter As Range
Set Source = ActiveDocument
For i = 1 To Source.Sections.Count
Set Letter = Source.Sections(i).Range
Set Target = Documents.Add
Target.Range = Letter
Target.Sections(2).PageSetup.SectionStart = wdSectionContinuous
Target.SaveAs FileName:="Letter" & i
Target.Close
Next i
End Sub

For the email merge with attachments, see the article "Mail Merge to E-mail
with Attachments" at:

http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm

You may also get some other ideas from the "Individual Merge Letters" item
on fellow MVP Graham Mayor's website at:

http://www.gmayor.com/individual_merge_letters.htm

--
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