MAILMERGE IF condition - long text strings

P

PromisedOyster

I get the error message: String is longer than 255 characters if I
execute the following code AND the length of oTrueText is greater than
255 characters.

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

Is there any way around this?

I want to create an IF condition with quite long text strings
 
D

Doug Robbins - Word MVP

Use an IncludeText field in place of the oTrueText and have the string in
the file that is referred to in the IncludeText Field.

--
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
 
M

macropod

Hi Doug (and PromisedOyster),

Inserting an INCLUDETEXT field via the Addif method doesn't work. Mainly
because inserting the INCLUDETEXT field in code requires the insertion range
to be available and, until the Addif process is complete, the target range
doesn't exist. The workaround is to insert a 'token' of some sort (eg the
string 'oTrueText') where the TRUE condition goes, then replace that 'token'
after the Addif process has completed. Whilst you could then put the
INCLUDETEXT field in that spot, you might find it's equally possible to
replace it with the contents of oTrueText explicitly.

Cheers
 
D

Doug Robbins - Word MVP

I would never use code to create a mailmerge main document.

--
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

macropod said:
Hi Doug (and PromisedOyster),

Inserting an INCLUDETEXT field via the Addif method doesn't work. Mainly
because inserting the INCLUDETEXT field in code requires the insertion
range
to be available and, until the Addif process is complete, the target range
doesn't exist. The workaround is to insert a 'token' of some sort (eg the
string 'oTrueText') where the TRUE condition goes, then replace that
'token'
after the Addif process has completed. Whilst you could then put the
INCLUDETEXT field in that spot, you might find it's equally possible to
replace it with the contents of oTrueText explicitly.

Cheers

--
macropod
[MVP - Microsoft Word]


Doug Robbins - Word MVP said:
Use an IncludeText field in place of the oTrueText and have the string in
the file that is referred to in the IncludeText Field.

--
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top