View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP on news.microsoft.com Doug Robbins - Word MVP on news.microsoft.com is offline
external usenet poster
 
Posts: 407
Default How to add a mergefield to a blank document via visual basic

Use:

ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, "Mergefield
FirstName"


--
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, originally posted via msnews.microsoft.com

"fledeboer" wrote in message
...
Hello,

I am trying to write an add-in with visual studio 2008 (visual basic) for
Word2007 to let users build a mailmerg document template. In the second
steo
these mergefields should handle values from an active directory. To do
this I
would like to have a ribbongroup with some buttons in it. By pressing a
button a mail merge field e.g. {MERGEFIELD firstname} should be inserted
at
the current cursor position.

I don't know how to use the Filed.Add method. Maybe someone has an example
for me?