Word Merge - All At One

  • Thread starter יריב החביב
  • Start date
×

יריב החביב

Hello,

We have to merge 30 letters to one data source .

The letters are separate entity.

Is there any way to do it in one action insted of every letter seperately ?

if the answer is Yes, please tell me how.

thank you
 
P

Peter Jamieson

If you are trying to ensure that the output for each recipient is all
produced together, then the simplest approach is /probably/ to combine all
the letters into a single document and merge that, particularly if this
operation needs to be repeated periodically. My guess is that the approach
where you automate the process so that you open each document and merge one
record, the repeat the process, is likely to be harder to get right.

However, if you also need to use different paper for first page/subsequent
pages and that kind of thing you will need to test that you can do that with
the printer(s) you are using.
 
×

יריב החביב

thank you Graham, But it is still not answer

my question (or that i don't understand ...)

Is there a way to "Choose the data source" (one datasource)

for 30 letter's in one action (instead of choosing the datasource seperately
for each letter) ???

thank you
 
×

יריב החביב

Thank you Peter,

But I must leave the letter's separately

Because on each production of a letter the datasource (from access) is
changing

and only one leeter is producing
 
G

Graham Mayor

Now it is my turn not to understand :)

The principle of mail merge is that you create a standard letter with the
text common to all and attach the data source to insert the variable
information from that data source. Thus if there are thirty records in your
data source you will get thirty letters.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

Doug Robbins - Word MVP

I gather that what you are doing is creating multiple letters, each one
containing different text, but each one populated with data from the same
one record in the data source. While mail merge can be made to do that, it
is not the intended purpose of mailmerge.

Instead of using mailmerge, I would have a template for each letter and I
would use VBA code to create a letter from each template and populate
docvariable fields in each letter with the appropriate data from the data
source.

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

יריב החביב

Yes,
i have 30 standard letter's and i want them as they are (30 standard . . .)

but i want them to use the same datasource, and i want to save time

by choose this datasource for all of them in one action, instead of each
letter

seperately.

THANK YOU



תודה רבה
 
G

Graham Mayor

The following macro will attach the same data source - here "D:\My
Documents\Test\Names Data.doc"
to all the files in a folder selected from the dialog.

Dim fDialog As FileDialog
Dim DataFile As String
DataFile = "D:\My Documents\Test\Names Data.doc"

Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select Folder containing the letters and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
DocDir = .SelectedItems.Item(1)
If Right(DocDir, 1) <> "\" Then DocDir = DocDir + "\"
End With
On Error Resume Next

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If

DocList = Dir$(DocDir & "*.doc")
Do While DocList <> ""
Documents.Open DocList
With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource DataFile
End With
Documents.Close wdSaveChanges
DocList = Dir$()
Loop


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
×

יריב החביב

thank you,

it is geting closer but i still have not reach the target.

the dialog box open and i can select the folder but i dont see the files
(letters)

i choose the folder (without seeing the files)

and it run, but finaly the letters not conected to the data source)
 
P

Peter Jamieson

You could try making a couple of changes to Graham's suggested code,
something like the following. This updates the mail merge data source for
each file, then performs the merge immediately.

Dim fDialog As FileDialog
Dim DataFile As String
' I prefer to store a reference to the documents the code is working with
Dim oDoc As Word.Document
DataFile = "D:\My Documents\Test\Names Data.doc"

Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select Folder containing the letters and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
DocDir = .SelectedItems.Item(1)
If Right(DocDir, 1) <> "\" Then DocDir = DocDir + "\"
End With
On Error Resume Next

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If

' All the changes are in this part
DocList = Dir$(DocDir & "*.doc")
Do While DocList <> ""
Set oDoc = Documents.Open(DocList)
With oDoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource DataFile
.Destination = wdSendToPrinter
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
End With
' If you don't actually need to save the new data source do this
oDoc.Close wdDoNotSaveChanges
' But if you might need to re-run the merge agains thte data source you are
currently using, do this
' oDoc.Close wdSaveChanges
Set oDoc = Nothing
DocList = Dir$()
Loop
 
S

Suzanne S. Barnhill

Or the letters could use IncludeText fields to pull bookmarked text from a
source document, which could be updated as needed.
 
G

Graham Mayor

You are not supposed to see the files. The macro assumes that you know where
they are saved. It runs on ALL the files in the folder. See Peter's
contribution to the thread.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
×

יריב החביב

thank you

I think i get closer, now another dialog box open and

ask me to select table (excel sheet's - i changed the suffix code of the
place of the

source to .xls ) for every word document that i have

in the file, but still the document's not conected to the source
 
P

Peter Jamieson

in the file, but still the document's not conected to the source

You may need to follow the instructions here:

http://support.microsoft.com/kb/825765/en-us
ask me to select table (excel sheet's - i changed the suffix code of the
place of the

source to .xls ) for every word document that i have

For .xls sources try replacing

..OpenDataSource DataFile

with this

' you can put these at the top of your macro if you prefer
Dim strSheetName As String
strSheetName = "Sheet4"

..OpenDataSource _
Name:=DataFile, _
SQLStatement:="SELECT * FROM [" & strSheetName & "$]"
 

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