Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Guabble Guabble is offline
external usenet poster
 
Posts: 3
Default Automating Mailmerge using CSV results in squares / Japanese characters

Im using ASp.net to automate a mail merge using a CSV file and a word
doc however the resulting file is just garbage. none of the merge
fields are filled in, and the pages are made up of lots of small
squares due to I would imagine encoding problems, as there are a
couple of Japanese Yen symbols in there too.

How do I get encode the resultant file or get it to work properly).
Using ASP.net 2, Word 2003 and Excel to create the CSV file.

many thanks
Mike

My Code is this

Dim aLocalWdApp As Word.Application
Dim aLocalDoc As Word.Document
Dim strConnect As String
Dim strFilePath As String
strFilePath =
HttpContext.Current.Server.MapPath(db.m_Global_Doc ument_Path)
PrintMergeDocuments = False
aLocalWdApp = New Word.Application


aLocalWdApp.ChangeFileOpenDirectory(strFilePath)

aLocalDoc = aLocalWdApp.Documents.Open(FileName:=strFilePath &
strTemplateName, Format:=4, Encoding:=65001)


aLocalWdApp.Visible = True
aLocalWdApp.ActiveDocument.MailMerge.MainDocumentT ype = 0
'WdMailMergeMainDocType.wdFormLetters

aLocalDoc.MailMerge.OpenDataSource(strFilePath &
ConstantsClass.cCSVHEADINGS_FILENAME, , , True, , False)

aLocalDoc.MailMerge.Destination = 0 ' wdSendToNewDocument

If aLocalDoc.MailMerge.State = 2 Then ' wdMainAndDataSource
Then
aLocalDoc.MailMerge.Execute()
end if

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Automating Mailmerge using CSV results in squares / Japanese characters

It is probably worth seeing if setting the DefaultCPG registry value
described in

http://support.microsoft.com/kb/290981/en-us

(It's also possible that opening the document in Word with an explicit
encoding , saving it as a Word document, then using that as the data source
for a merge, as described in that article, might do the trick).

If your data source has 255 columns or fewer, and you are using Word 2003,
you can try the approach using .odc and SCHEMA.INI that I described in the
conversation beginning at

http://groups.google.com/group/micro...unicode&rnum=1

I would be interested to know whether either of these things fixes it for
you.

Peter Jamieson

"Guabble" wrote in message
oups.com...
Im using ASp.net to automate a mail merge using a CSV file and a word
doc however the resulting file is just garbage. none of the merge
fields are filled in, and the pages are made up of lots of small
squares due to I would imagine encoding problems, as there are a
couple of Japanese Yen symbols in there too.

How do I get encode the resultant file or get it to work properly).
Using ASP.net 2, Word 2003 and Excel to create the CSV file.

many thanks
Mike

My Code is this

Dim aLocalWdApp As Word.Application
Dim aLocalDoc As Word.Document
Dim strConnect As String
Dim strFilePath As String
strFilePath =
HttpContext.Current.Server.MapPath(db.m_Global_Doc ument_Path)
PrintMergeDocuments = False
aLocalWdApp = New Word.Application


aLocalWdApp.ChangeFileOpenDirectory(strFilePath)

aLocalDoc = aLocalWdApp.Documents.Open(FileName:=strFilePath &
strTemplateName, Format:=4, Encoding:=65001)


aLocalWdApp.Visible = True
aLocalWdApp.ActiveDocument.MailMerge.MainDocumentT ype = 0
'WdMailMergeMainDocType.wdFormLetters

aLocalDoc.MailMerge.OpenDataSource(strFilePath &
ConstantsClass.cCSVHEADINGS_FILENAME, , , True, , False)

aLocalDoc.MailMerge.Destination = 0 ' wdSendToNewDocument

If aLocalDoc.MailMerge.State = 2 Then ' wdMainAndDataSource
Then
aLocalDoc.MailMerge.Execute()
end if


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Guabble Guabble is offline
external usenet poster
 
Posts: 3
Default Automating Mailmerge using CSV results in squares / Japanese characters

I have noticed that when you actually open the document, its encoding
(i think) is wrong. I have tried the UK (20285), Auto Detect (50001),
UTF-8 ( 65001), MSOENCODINGUSASCII (20127) & MSOENCODINGWESTERN (1252)
and many more . It works if I click on it in Explorer. I am running
the code locally so I dont think it would be a server setting). What
could be doing this?

Dim aLocalWdApp As Word.Application

Dim aLocalDoc As Word.Document

Dim strFilePath As String

strFilePath =
HttpContext.Current.Server.MapPath(db.m_Global_Doc ument_Path)

Dim strTemplateName As String = "Reminder1Letters.dot"

aLocalWdApp = New Word.Application

aLocalWdApp.ChangeFileOpenDirectory(strFilePath)

aLocalDoc = aLocalWdApp.Documents.Open(FileName:=strFilePath &
strTemplateName, Format:=4, Encoding:=20285)

aLocalWdApp.Visible = True ' PUT A BREAK HERE

aLocalDoc.Close()

aLocalWdApp.Quit()

  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Guabble Guabble is offline
external usenet poster
 
Posts: 3
Default Automating Mailmerge using CSV results in squares / Japanese characters

now fixed!

It was the line

aLocalDoc = aLocalWdApp.Documents.Open(FileName:=strFilePath &
strTemplateName, Format:=4, Encoding:=20285)

i took out the last 2 arguments and its fine, the encoding, and the
Word document type, ie

aLocalDoc = aLocalWdApp.Documents.Open(FileName:=strFilePath &
strTemplateName)




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SimSun, MS Mincho, Chinese/Japanese characters? rhewell Microsoft Word Help 3 August 31st 12 06:34 AM
Help merging japanese characters jennifer72401 Mailmerge 2 February 19th 06 06:32 PM
Automating MailMerge tony Mailmerge 1 December 19th 05 10:18 PM
Characters appear as squares Joelle Microsoft Word Help 4 October 13th 05 09:58 PM
How do I use Japanese characters in Ms Word 2000? *Besu* Microsoft Word Help 1 December 3rd 04 02:51 PM


All times are GMT +1. The time now is 02:46 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"