Merging with non default record separator

C

ClaudeV

I use Word mailmerge out of VB 6.0.
With an SQL procedure I create a *.txt file using an SQL
database and merge it to Word, using Word templates. What
is special about my Word templates is that I use "#" as
record separator instead of the default CRLF, which allows
me to use CRLF in bigger database fields.
With Word97 and Word 2000, this worked pretty well. Just
had to save the template once with my desired parameters.
With Word2002, it isn't true any more. First I had to
implement the OpenDatSource command in VB to avoid a
runtime error with Word opening the "Select * from ..."
box. The second problem is, that Word doesn't remember to
use "#" as the record separator and opens the Separator
Box everytime a template is opened out of VB. This would
not be a greater problem as it permits me to indicate the
correct seperator and than continues normally.
Unfortunately, this is is not the entire thing, because
when there are in fact any mergefields with CRLF's
Word2000 returns an error, finding the correct fields
number anymore.
It surely has to do with the OLEDB thing, but I just can't
manage to find out. It would be great if someone could
help me out of this.
 
P

Peter Jamieson

Generally speaking, if something worked with VB/VBA in Word 2000 and does
not in Word 2002/3, try adding the parameter

Subtype:=wdMergeSubtypeWord2000

to the OpenDataSource call when opening a data source in Word 2002/3.

(This may not be straightforward if you are trying to automate both Word
2000/97 and Word 202/2003 in the same code.)
 
C

ClaudeV

Thank you for your suggestion but I've already tried it
out without any result.
But let me recall the differences I met with Word 2002
when merging:
1. First there is that SQL check window "Select * from .."
that can be removed with the "SQLSecurtiyCheck = 0" Option
in the registry or with the OpenDataSource command under
VB.
2. Then there is the "Set the delimiters" window which
opens everytime I call for a template from VB (not when
opened directly form the Explorer).
3. Even after telling Word to use "#" as record delimiter,
it refuses nevertheless to merge correctly if there is any
CRLF in one of the merged fields, acting as if CRLF still
was the delimiter.
Now, maybe I have to introduce some further command under
VB to tell Word to use "#" as the record delimiter when
merging. But, does anyone know that command? As I said, it
isn't enough adding Subtype:=wdMergeSubtypeWord2000 to the
Opendatsource call.

Best regards,
Claude
 
P

Peter Jamieson

Thank you for your suggestion but I've already tried it
out without any result.
OK.

Now, maybe I have to introduce some further command under
VB to tell Word to use "#" as the record delimiter when
merging. But, does anyone know that command?

As far as I know,
a. if Word is connecting using ODBC, it always requires the record
delimiter to be CRLF. You can set the /field/ delimiter using a SCHEMA.INI
file.
b. if Word is connecting using its internal text converter, there is no way
to specify the delimiter in code, except perhaps to use Sendkey

I'm less sure about the options if Word is connecting using OLEDB

Can you post your OpenDataSource statement here, please?
 
C

ClaudeV

Here's the kind of statement I use in VB:
wd.ActiveDocument.MailMerge.OpenDataSource
Name:="C:\Path\database.txt",
SubType:=wdMergeSubTypeWord2000

Claude
 
C

ClaudeV

Hi Peter,
Just found out a solution. As I told before I had tried
two things: First the OpenDataSource statement in VB,
second the SQLSecurityCheck=0 Option in the Registry.
I just found out that it's enough to enter the last one
but withdraw the OpenDataSource statement under VB. Both
together don't work. The first doesn't go with the
delimiter change, the second does. Of course, I'm not
happy to withdraw the SQLSecurity check, but as long as I
have no other solution, I'm happy with it.
So, thanks for now. Maybe someone will get a better idea
later.
Yours sincerely,
Claude
 

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