MergeFields in Word

Soegaard
02-28-2001, 05:49 AM
How do I programatically (in VBA) set MergeFields in a Word document??

Thanks
Bjarne S.

karimahta
03-02-2001, 08:54 AM
(I had a pretty HTML rendered answer, but the parsing seems to have disappeared so ...)

I am not sure what you actually are asking for so I will answer two intepretations of your question:
1) To add an actual mergefield to your main document use somthing like ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="LastName"
Here LastName indicates the merge field to add.

2) To actually add a value to a merge field in your document, I could only suggest setting up a table in a new document using code and linking it as the data source for the document.

NOTE: If you are not already aware, you can get a lot of clues by opening a word document and recording a macro and perform the tasks you want to perform. This will get you a long way to having the correct code.

HTH

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum