Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Problems with mail merge
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.R ange, 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? |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Problems with mail merge
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. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org PromisedOyster wrote: 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.R ange, 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? |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Problems with mail merge
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 ); Graham Mayor wrote: 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. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org PromisedOyster wrote: 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.R ange, 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? |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Problems with mail merge
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. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org PromisedOyster wrote: 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 ); Graham Mayor wrote: 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. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org PromisedOyster wrote: 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.R ange, 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? |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I mail merge to EMAIL from MS Word AND add a pdf attachment | Mailmerge | |||
Field problems with Mail Merge | Mailmerge | |||
Mail Merge Date Format Problems | Microsoft Word Help | |||
If statement problems in mail merge | Mailmerge | |||
Mail Merge - Parameter prompts twice... | Mailmerge |