Here you go Alexey. Thank you for your help.
And here is some of my code. I kind of have a couple of different things going on here that I’ll clean up once I get the Aspose merge working, but I’m generating the CSV file as well as defining the strings/variables that are used in the mailmerge.execute.
Try
'header
Dim i As Integer = 1
For i = 0 To ds.Tables(0).Rows.Count - 1
csvLine = String.Format("{0}{1},", csvLine, ds.Tables(0).Rows(i).Item(0))
csvline0 = String.Format("{0}{1},", csvline0, SetCSV(ds.Tables(0).Rows(i).Item(0)))
Next
csvLine = String.Format("{0}{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", csvLine, _division, _plaintiff, _defendant1, _defendant1_pc, _defendant2, _casenumber, _casenumber2, _casenumber3, _casenumber4, _defendants, _SectionSymbol, _defendantnum, _dftresp_last_name)
csvline0 = String.Format("{0}{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", csvline0, SetCSV(_division), SetCSV(_plaintiff), SetCSV(_defendant1), SetCSV(_defendant1_pc), SetCSV(_defendant2), SetCSV(_casenumber), SetCSV(_casenumber2), SetCSV(_casenumber3), SetCSV(_casenumber4), SetCSV(_defendants), SetCSV(_SectionSymbol), SetCSV(_defendantnum), SetCSV(_dftresp_last_name))
w.WriteLine(csvLine)
csvline0 = Replace(csvline0, Chr(34) + Chr(34), Chr(34))
'detail
csvLine = String.Empty
For i = 0 To ds.Tables(0).Rows.Count - 1
csvLine = String.Format("{0}{1},", csvLine, SetCSV(ds.Tables(0).Rows(i).Item(1)))
Next
csvLine = String.Format("{0}{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", csvLine, SetCSV(division), SetCSV(plaintiff), SetCSV(defendant1), SetCSV(defendant1_pc), SetCSV(defendant2), SetCSV(casenumber.ToUpper), SetCSV(casenumber2.ToUpper), SetCSV(casenumber3.ToUpper), SetCSV(casenumber4), SetCSV(defendants), SetCSV(sectionSymbol), SetCSV(defendantNum), SetCSV(defendant_last_name).ToUpper)
csvline1 = csvLine
w.WriteLine(csvLine)
w.Flush()
w.Close()
'Set the template path
templatePath = String.Format("{0}\{1}", templatePath, templateFilename)
'Get the target path
Dim targetPath = String.Format("{0}\final.docx", userDirectory)
Dim targetPDF As String = String.Format("{0}\final.pdf", userDirectory)
Dim letter As New Document(templatePath)
letter.MailMerge.Execute(New String() {
csvline0
},
New Object() {
csvline1})
letter.Save(targetPath)
Public Function SetCSV(field As String) As String
SetCSV = Chr(34) & field & Chr(34)
End Function
And, finally, here are the two full strings that contain the merge field names and the corresponding values that I’m trying to send to the merge template.
"""full_discovery_date"",""pretrial_motions_date"",""govt_responses_due"",""dft_reply_date"",""pretrial_materials_date"",""pretrial_conference_date"",""trial_date_time"",""order_date"",""division"",""plaintiff"",""defendant1"",""defendant1_pc"",""defendant2"",""casenumber"",""casenumber2"",""casenumber3"",""casenumber4"",""defendants"",""SS"",""num"""
"""January 25, 2022"" ,""January 25, 2022"" ,""January 25, 2022"",""January 25, 2022"",""January 25, 2022"" ,""January 25, 2022 at 1:00 AM"",""January 25, 2022 at 9:00 AM. "",""January 25, 2022"",""DALLAS DIVISION"",""UNITED STATES OF AMERICA"","" John Doe "",""John Doe "","" John Doe "",""3:21-CR-00070-B"",""3:21-CR-70"",""3:21-CR-00070-B-1"",""3:02-CR-070-01-B"",""Defendant"",""§"",""(1)"""
image001.gif (7.68 KB)
CRPTO.docx (44.4 KB)
(Attachment mergeBNFDMXUNSO.csv is missing)