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
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