Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / September 2006

Tip: Looking for answers? Try searching our database.

Problems with mail merge

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PromisedOyster - 29 Aug 2006 00:14 GMT
We have a C# program that programatically inserts merge fields and into

a Word document. There are basically two different types of merge field

that get inserted:

1. An ordinary merge field
2. An If merge field

Both merge fields insert perfectly well and is getting used in
production extensively.

With the ordinary merge field, the font that gets assigned to the newly

inserted mergefield is the current one (ie the one used for the
surrounding text).  However, with the if merge field, the font that
gets applied is the default font, ie Times New Roman. Ideally, this
should behave in exactly the same manner and get the current font.

See code below for example calls:

_wordDoc.MailMerge.Fields.Add(_wordApp.Selection.Range, fieldName);

Word.MailMergeField condition =
_wordDoc.MailMerge.Fields.AddIf(_wordApp.Selection.Range
                               ,fieldName
                               ,wdComparison
                               ,ref oCompareTo
                               ,ref oMissing
                               ,ref oTrueText
                               ,ref oMissing
                               ,ref oFalseText
                               );

Although I could reselect and apply a font, it seems cumbersome. Is
there an easier way?

Is this a bug or am I doing something wrong?
Graham Mayor - 29 Aug 2006 06:32 GMT
I don't know C programming, but you need to add a \*charformat switch to
your conditional field to get it to adopt the style of the text into which
it is inserted.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> We have a C# program that programatically inserts merge fields and
> into
[quoted text clipped - 37 lines]
>
> Is this a bug or am I doing something wrong?
PromisedOyster - 05 Sep 2006 14:23 GMT
I changed the code as follows but this did not fix the problem

Word.MailMergeField condition =
_wordDoc.MailMerge.Fields.AddIf(_wordApp.Selection.Range
                               ,fieldName + "\\* charformat"
                               ,wdComparison
                               ,ref oCompareTo
                               ,ref oMissing
                               ,ref oTrueText
                               ,ref oMissing
                               ,ref oFalseText
                               );
> I don't know C programming, but you need to add a \*charformat switch to
> your conditional field to get it to adopt the style of the text into which
[quoted text clipped - 49 lines]
> >
> > Is this a bug or am I doing something wrong?
Graham Mayor - 05 Sep 2006 14:53 GMT
The space should really be before the slash not after the asterisk.
" \\*charformat" though I suspect the real problem is that the field is not
being updated.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I changed the code as follows but this did not fix the problem
>
[quoted text clipped - 61 lines]
>>>
>>> Is this a bug or am I doing something wrong?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.