Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Abraet
 
Posts: n/a
Default Using COM for MailMerge need multiple output files

I am using COM through Lotus Notes to read in a txt file and then use a
template and mail merge to create Word Letters. These letters will then be
electronically mailed, faxed or USPS mailed depending on the recepient's
preference (kept in a separate file). I have the mail merge part sorta
working, but only if I create separate input files for each letter. What I
want, however, is a one file to many file relationship. That is my text file
has many records that I want to produce separate Word files.

Here's a copy of my code. Any ideas??

MSWord.Documents.Open(SmartMasterDirectory + TemplateName$)
With MSWord.ActiveDocument.MailMerge
.OpenDataSource(PathName$ + fileName$)
.Destination = 0
.Execute
End With
'Save Merged document with file name
Call MSWord.ActiveDocument.SaveAs (AgentLetterDirectory + Left$(fileName$,
Instr(fileName$,"."

Annette
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default Using COM for MailMerge need multiple output files

See the "Individual Merge Letters" item on fellow MVP Graham Mayor's website
at:

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

If you are using Word XP or later, the "Add-in to Merge Letters to Separate
Files" that I have written and that can be downloaded from that site will
allow you to create each letter as a separate file with a filename taken
from a field in the data source with a minimum of fuss.


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

"Abraet" wrote in message
...
I am using COM through Lotus Notes to read in a txt file and then use a
template and mail merge to create Word Letters. These letters will then be
electronically mailed, faxed or USPS mailed depending on the recepient's
preference (kept in a separate file). I have the mail merge part sorta
working, but only if I create separate input files for each letter. What I
want, however, is a one file to many file relationship. That is my text
file
has many records that I want to produce separate Word files.

Here's a copy of my code. Any ideas??

MSWord.Documents.Open(SmartMasterDirectory + TemplateName$)
With MSWord.ActiveDocument.MailMerge
.OpenDataSource(PathName$ + fileName$)
.Destination = 0
.Execute
End With
'Save Merged document with file name
Call MSWord.ActiveDocument.SaveAs (AgentLetterDirectory + Left$(fileName$,
Instr(fileName$,"."

Annette



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Abraet
 
Posts: n/a
Default Using COM for MailMerge need multiple output files

Thanks Doug. I saw this post, but didn't think it would work with COM, but
I'm not very experienced with it. If I follow the directions at the site to
install the addin, will it have COM objects exposed for my use in Notes?
--
Annette


"Doug Robbins - Word MVP" wrote:

See the "Individual Merge Letters" item on fellow MVP Graham Mayor's website
at:

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

If you are using Word XP or later, the "Add-in to Merge Letters to Separate
Files" that I have written and that can be downloaded from that site will
allow you to create each letter as a separate file with a filename taken
from a field in the data source with a minimum of fuss.


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

"Abraet" wrote in message
...
I am using COM through Lotus Notes to read in a txt file and then use a
template and mail merge to create Word Letters. These letters will then be
electronically mailed, faxed or USPS mailed depending on the recepient's
preference (kept in a separate file). I have the mail merge part sorta
working, but only if I create separate input files for each letter. What I
want, however, is a one file to many file relationship. That is my text
file
has many records that I want to produce separate Word files.

Here's a copy of my code. Any ideas??

MSWord.Documents.Open(SmartMasterDirectory + TemplateName$)
With MSWord.ActiveDocument.MailMerge
.OpenDataSource(PathName$ + fileName$)
.Destination = 0
.Execute
End With
'Save Merged document with file name
Call MSWord.ActiveDocument.SaveAs (AgentLetterDirectory + Left$(fileName$,
Instr(fileName$,"."

Annette




  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default Using COM for MailMerge need multiple output files

Sorry, I can't help there. It is not something that I know anything about.

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

"Abraet" wrote in message
...
Thanks Doug. I saw this post, but didn't think it would work with COM, but
I'm not very experienced with it. If I follow the directions at the site
to
install the addin, will it have COM objects exposed for my use in Notes?
--
Annette


"Doug Robbins - Word MVP" wrote:

See the "Individual Merge Letters" item on fellow MVP Graham Mayor's
website
at:

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

If you are using Word XP or later, the "Add-in to Merge Letters to
Separate
Files" that I have written and that can be downloaded from that site will
allow you to create each letter as a separate file with a filename taken
from a field in the data source with a minimum of fuss.


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

"Abraet" wrote in message
...
I am using COM through Lotus Notes to read in a txt file and then use a
template and mail merge to create Word Letters. These letters will then
be
electronically mailed, faxed or USPS mailed depending on the
recepient's
preference (kept in a separate file). I have the mail merge part sorta
working, but only if I create separate input files for each letter.
What I
want, however, is a one file to many file relationship. That is my text
file
has many records that I want to produce separate Word files.

Here's a copy of my code. Any ideas??

MSWord.Documents.Open(SmartMasterDirectory + TemplateName$)
With MSWord.ActiveDocument.MailMerge
.OpenDataSource(PathName$ + fileName$)
.Destination = 0
.Execute
End With
'Save Merged document with file name
Call MSWord.ActiveDocument.SaveAs (AgentLetterDirectory +
Left$(fileName$,
Instr(fileName$,"."

Annette






  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Using COM for MailMerge need multiple output files

What you probably need to do is convert the code at the bottom of the
article ("Print individual merge letters from a merged document - doing it
the old way") into Lotusscript or whatever it is you are using. I can't help
with that conversion as I don't know Lotusscript.

Or you can try converting the following VBA (which does one merge for each
record in the data source) into Lotusscript.

Sub ProduceOneDocPerSourceRec()
Dim intSourceRecord
Dim objMerge As Word.MailMerge
Dim strOutputDocumentName As String
Dim TerminateMerge As Boolean

' Need to set up this object as the ActiveDocument changes when the ' merge
is performed. Besides, it's clearer.

Set objMerge = ActiveDocument.MailMerge
With objMerge

' If no data source has been defined, do it here using OpenDataSource.
' But if it is already defined in the document, you should not need to
define it here.

' .OpenDataSource _
' Name:="whatever"

intSourceRecord = 1
TerminateMerge = False

Do Until TerminateMerge
..DataSource.ActiveRecord = intSourceRecord

' if we have gone past the end (and possibly, if there are no records)
' then the Activerecord will not be what we have just tried to set it to

If .DataSource.ActiveRecord intSourceRecord Then
TerminateMerge = True
' the record exists
Else

' while we are looking at the correct activerecord,
' create the document path name
' e.g. something like the following, but in this case
' each lastname must be unique (and must not contain
' characters that are not allowed in a file name)
strOutputDocumentName = _

"c:\mymergeletters\_" & _
..DataSource.Datafields("lastname").Value & _
" letter.doc"
..DataSource.FirstRecord = intSourceRecord
..DataSource.LastRecord = intSourceRecord
..Destination = wdSendToPrinter 'please check the constant name
..Execute

' The Activedocument is always the output document
' Add any parameters you need to these calls
ActiveDocument.SaveAs strOutputDocumentName
ActiveDocument.Close
intSourceRecord = intSourceRecord + 1
End If
Loop
End With
End Sub

Peter Jamieson

"Abraet" wrote in message
...
Thanks Doug. I saw this post, but didn't think it would work with COM, but
I'm not very experienced with it. If I follow the directions at the site
to
install the addin, will it have COM objects exposed for my use in Notes?
--
Annette


"Doug Robbins - Word MVP" wrote:

See the "Individual Merge Letters" item on fellow MVP Graham Mayor's
website
at:

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

If you are using Word XP or later, the "Add-in to Merge Letters to
Separate
Files" that I have written and that can be downloaded from that site will
allow you to create each letter as a separate file with a filename taken
from a field in the data source with a minimum of fuss.


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

"Abraet" wrote in message
...
I am using COM through Lotus Notes to read in a txt file and then use a
template and mail merge to create Word Letters. These letters will then
be
electronically mailed, faxed or USPS mailed depending on the
recepient's
preference (kept in a separate file). I have the mail merge part sorta
working, but only if I create separate input files for each letter.
What I
want, however, is a one file to many file relationship. That is my text
file
has many records that I want to produce separate Word files.

Here's a copy of my code. Any ideas??

MSWord.Documents.Open(SmartMasterDirectory + TemplateName$)
With MSWord.ActiveDocument.MailMerge
.OpenDataSource(PathName$ + fileName$)
.Destination = 0
.Execute
End With
'Save Merged document with file name
Call MSWord.ActiveDocument.SaveAs (AgentLetterDirectory +
Left$(fileName$,
Instr(fileName$,"."

Annette






Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert multiple text files in microsoft word DennisM Microsoft Word Help 7 May 14th 06 04:15 PM
Importing multiple rtf files Lawrence Microsoft Word Help 1 August 18th 05 07:38 PM
How do I open multiple Word 2003 files to display on dual monitors mally Microsoft Word Help 6 July 4th 05 11:00 AM
Working on multiple word files from a single file???? Rich New Users 5 May 30th 05 03:10 PM
How can I insert multiple files at once into a document? Confused Word User Microsoft Word Help 1 December 10th 04 06:12 PM


All times are GMT +1. The time now is 07:35 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"