Variables in a word doc?

  • Thread starter Thread starter Jimi
  • Start date Start date
J

Jimi

Hi

I need to create a master word document, copies of which will be sent to
multiple users. For the most part, all the info will be the same, except
each individual word doc will have to have info inserted in that is specific
to the user (eg. name). Is there a way to do this? I'm open to running
scripts or using the word COM object or it there's just some way to pass
info through to a word doc?

This is an example of what the Master will look like:
<Date>

Dear <Name>

Standard content.

Regards
Jimi

and then the copy to go out will be:
22/09/2003

Dear Mr Bobbit

Standard content.

Regards
Jimi

Any suggestions?

P.S. the sent document needs to be protected which is why I haven't just
used a more simple Find/Replace technique on a RTF file.

Thanks
Jimi
 
Hi Jimi,

Use Mailmerge, then use some code to pull the merged file apart, apply
protection to each letter and then email it.

Here's some info on pulling the merge document apart:

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

and some of the code in the article "Mail Merge to E-mail with Attachments"
at

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

should be of use to you


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