Group:  General ยป microsoft.public.officedev
Thread: Accessing mailmerge fields within text boxes

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Accessing mailmerge fields within text boxes
trob 22.12.2005 11:36:03
I'm using Word 2003 SP2 and have a single page document containing a variety
of text, as well as some mailmerge fields.

I have recently added a few text boxes and within these text boxes I have
placed normal text and also mailmerge fields.

I'm (eventually) doing a mailmerge via VB macros and the problem I have is
that when I iterate through the fields on the document, I'm only ever seeing
the mailmerge fields on the 'main' document, not those in the text boxes.

I have played around using the following code to find out how many fields I
have;

application.ActiveDocument.MailMerge.Fields.Count

Again this reports only the fields which are NOT in text boxes.

So my query is, how do I access the mailmerge fields in the text boxes?

Cheers
Re: Accessing mailmerge fields within text boxes
Cindy M -WordMVP- <C.Meister-C[ at ]hispeed.ch> 24.12.2005 15:14:32
Hi =?Utf-8?B?dHJvYg==?=,

Do NOT try to use mail merge fields (or, by choice, any fields) in a text box.
Things in the Drawing Layer just aren't properly accessible to Word's internal
functionality. You can get to them programmatically by accessing that document
STORY (see STORYRANGES in the VBA Help), but...

If at all possible, use a FRAME (from the Forms toolbar) instead. That's
visible to Word's internal functionality. You can convert existing text boxes
to frames, using a button in Format/[graphic or whatever]/Textbox

[Quoted Text]
> I'm using Word 2003 SP2 and have a single page document containing a variety
> of text, as well as some mailmerge fields.
>
> I have recently added a few text boxes and within these text boxes I have
> placed normal text and also mailmerge fields.
>
> I'm (eventually) doing a mailmerge via VB macros and the problem I have is
> that when I iterate through the fields on the document, I'm only ever seeing
> the mailmerge fields on the 'main' document, not those in the text boxes.
>
> I have played around using the following code to find out how many fields I
> have;
>
> application.ActiveDocument.MailMerge.Fields.Count
>
> Again this reports only the fields which are NOT in text boxes.
>
> So my query is, how do I access the mailmerge fields in the text boxes?
>

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net