mailmerge to word from access creating a .PDF file

F

fmpaiola

Microsoft Access 2003.

I'm using the code below to create a mailmerge to word from access. I would
like
to know if it's possible to save to word each register from my database and
then it creates a .PDF file from each word file saved.

Thanks!!!

I forgot to send my code, then I'm sending now:

Private Sub cmd_Gerar_Contrato_Click()
On Error GoTo Err_cmd_Gerar_Contrato_Click

Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim strCaminho As String
On Error Resume Next

strCaminho = CurrentProject.Path & "\"

Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open(strCaminho & "Modelo - Contrato de NDF.doc")

wdApp.Visible = True

wdDoc.MailMerge.MainDocumentType = wdFormLetters
wdDoc.MailMerge.OpenDataSource Name:=CurrentProject.FullName, _
Connection:="QUERY qry_ConsultaDados_Para_Imprimir", _
sqlstatement:="SELECT * FROM
[qry_ConsultaDados_Para_Imprimir]"

wdDoc.MailMerge.Execute

Set wdDoc = Nothing
Set wdApp = Nothing

Exit_cmd_Gerar_Contrato_Click:
Exit Sub

Err_cmd_Gerar_Contrato_Click:

MsgBox Err.Description, vbCritical, "Aviso"
Resume Exit_cmd_Gerar_Contrato_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top