Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
SimSun, MS Mincho, Chinese/Japanese characters? | Microsoft Word Help | |||
Help merging japanese characters | Mailmerge | |||
Automating MailMerge | Mailmerge | |||
Characters appear as squares | Microsoft Word Help | |||
How do I use Japanese characters in Ms Word 2000? | Microsoft Word Help |