A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to add a mergefield to a blank document via visual basic



 
 
Thread Tools Display Modes
  #1  
Old April 1st, 2009, 11:54 AM posted to microsoft.public.word.mailmerge.fields
fledeboer
external usenet poster
 
Posts: 1
Default How to add a mergefield to a blank document via visual basic

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?
  #2  
Old April 1st, 2009, 12:43 PM posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP on news.microsoft.com
external usenet poster
 
Posts: 409
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?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.