Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Split merge document into separate docs

10 views
Skip to first unread message

John Wells

unread,
Sep 5, 2003, 3:47:25 PM9/5/03
to
I have searched through this forum and found a couple of
interesting things, but nothing that does what I need.
Here is what I need to do:

1. I have a huge spreadsheet that has info for over 2000
different offices. Each row has info specific to that
office.

2. I have a standard document that needs to be created for
each of these offices with data specific to that office
(contact name, address, phone #, etc)

3. I need to have a separate document, with a standard
naming convention created for each office. For instance,
the name of one may be LosAngeles_3219.rvw.doc. I can
easily create a column for the file names.

The mail merge is fairly easy, I can create a HUGE
document with all of the sites, but separating them
maually would be alot of work.

I know there is scripting that will do this, but I am not
real familiar with it. There was a message a few days back
from Doug Robbins that was very close, but the formatting
of the response was too messed up for me to figure out how
to fix it(just pasted weird into the VB editor). I am not
a VB guy....

I also found some code on a website that splits the doc
up, but just gives the output generic filenames. Very
close to what I need but just need to add the code for
changing the name.

Any help would be appreciated.

Thanks,

John


Doug Robbins - Word MVP

unread,
Sep 5, 2003, 7:06:08 PM9/5/03
to
Hi John,

Here's a method that I have used that involves creating a separate
catalog type mailmerge maindocument which creates a word document containing
a table in each row of which would be your data from the database that you
want to use as the filename.

You first execute that mailmerge, then save that file and close it. Then
execute the mailmerge that you want to create the separate files from and
with the
result of that on the screen, run a macro containing the following code
and when the File open dialog appears, select the file containing the table
created by the first mailmerge

Dim Source As Document, oblist As Document, DocName As Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter < oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter, 1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" & DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend

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
"John Wells" <jf.w...@ngc.com> wrote in message
news:304f01c373e6$87c65420$a401...@phx.gbl...

John Wells

unread,
Sep 8, 2003, 3:29:27 PM9/8/03
to
Thanks Doug - This worked perfectly after I reformatted
the code a bit except for one thing....

How do I get the hyperlinks in the merge template to move
over to the merged document? I have several hyperlinks
that point to bookmarks and/or headings within the
document that don't work in my new merged doc.

Thanks again,

John

>.
>

0 new messages