Aspose Words VBA programming within MS ACCESS

We are using Aspose Words and have a Com Wrapper that works just fine on our classic ASP website. We are trying to do a mailmerge from within MS Access (using a Form and a Module) and cannot get the mailmerge to work. Our Asp code uses mailmerge.executeAdo but MS Access usesDOA instead. The merge does not work. How do we get this to work? Here is the code:

Set asposeLicense = CreateObject("Aspose.Words.License") 
Call asposeLicense.SetLicense("Aspose.Words.lic") 
Set comHelper = CreateObject("Aspose.Words.ComHelper") 
Set comWrapper = CreateObject("AsposeComWrapper.Methods") 
Set builder = CreateObject("Aspose.Words.Documentbuilder")

Set qryMerge = db.CreateQueryDef(MergeQryName, strMergeComplete)
Set rstMergeData = qryMerge.OpenRecordset() 
With rstMergeData 
.MoveLast
.MoveFirst
Do While Not .EOF

Set docSource = comHelper.Open( strWordFileFull )

' NEED MAILERGE HERE USING THE ACTIVE RECORD

docSource.Save (strPDFFileFull)

.MoveNext
Loop
END With

Hi Mike,

Thanks for your inquiry. I am working on your query and will update you asap.

Hi Mike,

Thanks for your patience.

Unfortunately, Aspose.Words does not have mail merge method for DAO Recordset. I suggest you please use the MailMerge.ExecuteADO method to perform mail merge from an ADO Recordset object into the document. To create an object of ADO Recordset, you need to add reference of Microsoft ActiveX Data Objects x.x Library in MS Access.

Please use the following code snippet in MS Access to perform mail merge operation. Hope this helps you. Please let us know if you have any more queries.

Dim comHelper
comHelper = CreateObject("Aspose.Words.ComHelper")
Dim builder
builder = CreateObject("Aspose.Words.Documentbuilder")
'open document
Dim doc
doc = comHelper.Open("c:\Test30.docx")
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
'Use the ADO connection 
cn = CurrentProject.AccessConnection
'Create an instance of the ADO Recordset class,
'and set its properties
rs = New ADODB.Recordset
With rs
.ActiveConnection = cn
.Source = "SELECT * FROM Test"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open()
End With
doc.MailMerge.ExecuteADO(rs)
'Set the form's Recordset property to the ADO recordset
Me.Recordset = rs
rs = Nothing
cn = Nothing
doc.Save("c:\out.docx")