Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / April 2004

Tip: Looking for answers? Try searching our database.

Mail Merge problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GP - 08 Apr 2004 06:34 GMT
Hi,

I have an application which prepares the datasource file
for me and allows me to download the same on to my
desktop. When I download this file and save it on my PC,
it is always saving the file in unicode format which is
internally causing a problem during Mail Merge. When I
open this datasource file from my word template to merge,
word promts for delimiter and other options. In the
preview window it shows lot of special characters and when
I click on merge it fails and displays field errors.

I was able to resolve this by openning my text file
(Datasource file) and then saving it explicitly. After
this mail merge worked without any problems. Looks like
the format got changed or reset when I did a explicit save.

Note :  I have no problems in merging a file in ANSI
format with word. This happens only when the datafile is
in unicode format and only when the file is not saved or
overwritten.

Any thoughts on this..

Thanks
GP
Peter Jamieson - 08 Apr 2004 09:57 GMT
Do you know exactly which Unicode format is being used? Does your
application give you a choice? Even for a text file, the Unicoce text can be
represented in several different ways (16-bit big-endian Unicode, 16-bit
little-endian, UTF-8 and so on). What's more, a Unicode text file may or may
not start with a "marker character" which tells a Unicode-savvy application
something about the format. Generally speaking I would hope that UTF-8
encoding preceded by the UTF-8 encoded marker character would be correctly
recognised and handled by Word, but there might still be problems because
determining which characters are used for field/record/text delmiter is
logicially distinct from the issue of representation.

Signature

Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/

> Hi,
>
[quoted text clipped - 22 lines]
> Thanks
> GP
GP - 12 Apr 2004 05:43 GMT
Hi,
Thanks for that info.
My file gets saved in 16-bit little-endian format and as
you just pointed out, Word is unable to recognize field
and record delimiter.

Does word have any settings to handle this format.

Thanks
GP

>-----Original Message-----
>Do you know exactly which Unicode format is being used? Does your
[quoted text clipped - 36 lines]
>
>.
Peter Jamieson - 13 Apr 2004 08:35 GMT
> Does word have any settings to handle this format.

As far as I know there is nothing you can specify. If you have no control
over the format it's probably best to use a bit of code to automate the
"open and save" operation you are already doing, e.g.

Sub ConvertToUTF8()
' convert to a UTF8 format text file

' Needs error checking etc.
Dim oDoc as Word.Document

' change msoEncodingUnicodeLittleEndian to be the encoding you need. I think
this should
work.

Set oDoc = Documents.Open("the path name of the file you need to
convert.txt", _
 False, , False, , , , , , _
 wdOpenFormatEncodedText, _
 msoEncodingUnicodeLittleEndian, _
 False, False, , True)

' Several of the parameters here are optional or
' irrelevant - you can probably remove the lines from
' ReadOnlyRecommended to SaveAsAOCLetter

oDoc.SaveAs _
 FileName:="the path name of the file to convert to.txt", _
 FileFormat:=wdFormatUnicodeText, _
 AddToRecentFiles:=False, _
 ReadOnlyRecommended:=False, _
 EmbedTrueTypeFonts:=False, _
 SaveNativePictureFormat:=False, _
 SaveFormsData:=False, _
 SaveAsAOCLetter:=False, _
 Encoding:=msoEncodingUTF8, _
 InsertLineBreaks:=False, _
 AllowSubstitutions:=False, _
 LineEnding:=wdCRLF

oDoc.Close Savechanges:=False
Set oDoc = Nothing
End Sub

or

Sub ConvertToWord()
' convert to a Word document file

' Needs error checking etc.
Dim oDoc as Word.Document

' change msoEncodingUnicodeLittleEndian to be the encoding you need. I think
this should
work.

Set oDoc = Documents.Open("the path name of the file you need to
convert.txt", _
 False, , False, , , , , , _
 wdOpenFormatUnicodeLittleEndian, _
 msoEncodingWestern, _
 False, False, , True)

' Several of the parameters here are optional or
' irrelevant - you can probably remove the lines from
' ReadOnlyRecommended to Encoding

oDoc.SaveAs _
 FileName:="the path name of the file to convert to.doc", _
 FileFormat:=wdFormatDocument, _
 AddToRecentFiles:=False, _
 ReadOnlyRecommended:=False, _
 EmbedTrueTypeFonts:=False, _
 SaveNativePictureFormat:=False, _
 SaveFormsData:=False, _
 SaveAsAOCLetter:=False, _
 Encoding:=msoEncodingUTF8, _
 InsertLineBreaks:=False, _
 AllowSubstitutions:=False, _
 LineEnding:=wdCRLF

oDoc.Close Savechanges:=False
Set oDoc = Nothing
End Sub

Personally I would be interested to know whether or not the Little Endian
format you have contains the marker bytes I mentioned. If it does, I'm not
sure the first of the above will help, and possibly not the second. If it
does not, it might be interesting to try saving manually as Little Endian
(in which case I'm fairly sure Word will add the marker) and see if that
file works. But if you can't actually get your application to generate that
format, it's really of academic interest only.

Signature

Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/

> Hi,
> Thanks for that info.
[quoted text clipped - 61 lines]
> >
> >.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.