Substring used one Mailmerge Fields

N

Nikon

In this office we have documents that take .dat files created from our Oracle
database, and use them for mail merge documents. Recently the size of the
fields has been increased and the merge documents don't fit some of the
fields anymore. I am wondering if there is any way, macro or otherwise, that
I can substring (shorten) the merge field so it still fits it's document.

Essentially what I would like to do is, figure out if a field is over a
certain length and if it is, cut it to a specified length. Eg. 25
characters.
 
P

Peter Jamieson

The simplest approach is to get your database people to do that in an Oracle
View, or in whatever tool is used to generate the .dat. Every other approach
is much more complicated. There's no simple field that lets you do, e.g. {
=left({ MERGEFIELD x },25) }

If that cannot be done, you can consider...
a. using Word VBA, the OpenDataSource method, and an Oracle SQL query to
get your data directly from Oracle. But you are limited to either 255 or 511
characters in the query (it depends) - that gets used up pretty quickly even
if the underlying query is very simple
b. depending on how Word connects to your .dat file, you /may/ be able to
use the same technique as in (a), but using Jet SQL instead of Oracle SQL.
Similar constraints as in (a) apply.
c. using Word VBA and MailMerge events to truncate each field before each
record is merged
d. preprocessing your .dat in some way to reduce the appropriate field
lengths.

Peter Jamieson
 

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