J
Jolyon Cox
I am using Word 2000 automation to invoke a mail-merge from a number of C++
applications. For various operational reasons not relevant here, the
applications create a tab-separated temporary file and call a library
function which uses the OpenDataSource method of the MailMerge object to
connect it to the template before using Execute to perform the merge. The
verson of Word actually in use is Word 2003.
It all works fine in the majority of cases, but one of the merge fields is
8-bit text used to print an i2of5 barcode using a special font - in this
format each 8-bit character encodes 2 barcode digits. Every now and again
the value in this field gets truncated - this is triggered by certain values
in the first data line of the file (i.e. the second line, as the first
contains field names), and thereafter applies to every instance of the field
in the data source. Moving the offending data line further down the file
"cures" the problem, but is not an option in practice.
By dropping the offending field into a simple text file and opening it
interactively with Word, I have established that Word is wrongly guessing the
file (or maybe only the field ?) to be encoded in UTF-8 - it brings up an
interactive dialogue which shows the guessed encoding and previews the text
as truncated. Selecting other encodings displays the text in various other
ways, but (critically) does not truncate it. Similarly, most values for the
barcode text are guessed by Word to be in various encodings which do not
truncate.
I have tried explicitly setting the WdOpenFormat parameter of OpenDataSource
to wdOpenFormatText, but it makes no difference - in fact, whatever value is
in this parameter seems to be ignored. Is there any other way I can get
these characters passed through without being corrupted, other than by
writing the data source file in 16-bit Unicode in the first place ? I am
reluctant to do this as it would mean either changing many programs or making
the library routine transcribe the entire data source file, which can be
quite large.
For the record, a value of the text string which causes problems is "(7å<Ó)"
(i.e. hex 28 37 e8 cc 4a 29), whereas values such as "(7èÌJ)" (i.e. hex 28
37 e5 3c d3 29) work OK. My PC is running Windows XP SP2 with UK English
regional settings (code page 0x0809).
Any help anyone can offer will be much appreciated.
Regards,
Jolyon
applications. For various operational reasons not relevant here, the
applications create a tab-separated temporary file and call a library
function which uses the OpenDataSource method of the MailMerge object to
connect it to the template before using Execute to perform the merge. The
verson of Word actually in use is Word 2003.
It all works fine in the majority of cases, but one of the merge fields is
8-bit text used to print an i2of5 barcode using a special font - in this
format each 8-bit character encodes 2 barcode digits. Every now and again
the value in this field gets truncated - this is triggered by certain values
in the first data line of the file (i.e. the second line, as the first
contains field names), and thereafter applies to every instance of the field
in the data source. Moving the offending data line further down the file
"cures" the problem, but is not an option in practice.
By dropping the offending field into a simple text file and opening it
interactively with Word, I have established that Word is wrongly guessing the
file (or maybe only the field ?) to be encoded in UTF-8 - it brings up an
interactive dialogue which shows the guessed encoding and previews the text
as truncated. Selecting other encodings displays the text in various other
ways, but (critically) does not truncate it. Similarly, most values for the
barcode text are guessed by Word to be in various encodings which do not
truncate.
I have tried explicitly setting the WdOpenFormat parameter of OpenDataSource
to wdOpenFormatText, but it makes no difference - in fact, whatever value is
in this parameter seems to be ignored. Is there any other way I can get
these characters passed through without being corrupted, other than by
writing the data source file in 16-bit Unicode in the first place ? I am
reluctant to do this as it would mean either changing many programs or making
the library routine transcribe the entire data source file, which can be
quite large.
For the record, a value of the text string which causes problems is "(7å<Ó)"
(i.e. hex 28 37 e8 cc 4a 29), whereas values such as "(7èÌJ)" (i.e. hex 28
37 e5 3c d3 29) work OK. My PC is running Windows XP SP2 with UK English
regional settings (code page 0x0809).
Any help anyone can offer will be much appreciated.
Regards,
Jolyon