I have a word document (which i attached) When I do a mail merge the font defaults to Arial. The code is below, thanks for any help.
- Code: Select all
Dim sSQL As String
Dim dsLetters As New DataSet
Dim sFullLetter As String
Dim letterPath = String.Empty
sCreditors = sCreditors.Remove(0, 1)
sSQL = "SP_PRINT_GROUPED_lETTERS '" + sCreditors.Remove(sCreditors.Length - 1, 1) + "'," + sReportId + "," + CStr(iUserId)
sSQL = sSQL.Replace(Chr(34), " '")
dsLetters = ReturnDataSet(sSQL)
Threading.Thread.Sleep(2000)
Dim dt As DataTable = ReturnDataTable(sSQL)
'get template
Dim sTemplateFile = dt.Rows(0)("TemplateFileName").ToString()
If sTemplateFile.Length < 1 Then
sTemplateFile = GetTemplateDoc(iUserId)
End If
Dim document As New Document(sApplicationPath + "Desktopmodules\AnnualReport\Uploads\" + CStr(iUserId) + "\" + sTemplateFile)
Try
If dsLetters IsNot Nothing Then
AddHandler document.MailMerge.MergeImageField, AddressOf DoMergeImage
document.MailMerge.Execute(dt)
sFullLetter = "\" + sLetterName + CStr(iUserId) + CStr(Now().Year) + CStr(Now().Month) + CStr(Now().Day) + CStr(Now().Minute) + CStr(Now().Second) + ".pdf"
letterPath = sApplicationPath + "Desktopmodules\AnnualReport\Uploads\" + CStr(iUserId) + sFullLetter
document.SaveToFile(letterPath, FileFormat.PDF)
iNoofPages = document.PageCount
document.Close()
RemoveHandler document.MailMerge.MergeImageField, AddressOf DoMergeImage
End If
Catch ex As Exception
WriteToEventLog("[CreateLetter] " + ex.Message, EventLogEntryType.Error, , )
Finally
End Try
Return letterPath
Derek.