G
Guabble
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_Document_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.MainDocumentType = 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
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_Document_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.MainDocumentType = 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