Depois de muuuuuuito procurar e não encontrar, aqui estou:
Qual código e onde vai para que ao clicar visualizar, abra no Word-Mala Direta apenas o registro que está aberto no Formulário do Access?
Atualmente quando clico em visualizar, abrem todos os Contratos da Mala Direta no Word.
-------------------------------------------------------------------------------------------------------------------------------------------
Private Sub VisualizarContrato_Click()
Dim AppWord As Object, strFinalDoc As String
strFinalDoc = CurrentProject.Path & "\ContratoEncore.docx"
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
Set DocWord = AppWord.Documents.Add(strFinalDoc)
With DocWord.Content.Find
.Execute findtext:="{DATACONTRATO}", replacewith:=DataContrato, Format:=True, Replace:=2
.Execute findtext:="{NRCONTRATO}", replacewith:=Me.NrContrato, Format:=True, Replace:=2
.Execute findtext:="{EMPREENDIMENTO}", replacewith:=Me.Empreendimento, Format:=True, Replace:=2
.Execute findtext:="{Vend1}", replacewith:=Nz(Me.Vend1), Format:=True, Replace:=2
.Execute findtext:="{Vend1CNPJ}", replacewith:=Nz(Me.Vend1CNPJ), Format:=True, Replace:=2
.Execute findtext:="{Vend1End}", replacewith:=Nz(Me.Vend1End), Format:=True, Replace:=2
.Execute findtext:="{Vend1Cidade}", replacewith:=Nz(Me.Vend1Cidade), Format:=True, Replace:=2
.Execute findtext:="{Vend1Estado}", replacewith:=Nz(Me.Vend1Estado), Format:=True, Replace:=2
.Execute findtext:="{Vend2}", replacewith:=Nz(Me.Vend2), Format:=True, Replace:=2
.Execute findtext:="{Vend2CNPJ}", replacewith:=Nz(Me.Vend2CNPJ), Format:=True, Replace:=2
.Execute findtext:="{Vend2End}", replacewith:=Nz(Me.Vend2End), Format:=True, Replace:=2
.Execute findtext:="{Vend2Cidade}", replacewith:=Nz(Me.Vend2Cidade), Format:=True, Replace:=2
.Execute findtext:="{Vend2Estado}", replacewith:=Nz(Me.Vend2Estado), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitNome}", replacewith:=Nz(Me.Vend1TitNome), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitCPF}", replacewith:=Nz(Me.Vend1TitCPF), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitIdentidade}", replacewith:=Nz(Me.Vend1TitIdentidade), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitOrgaoEstado}", replacewith:=Nz(Me.Vend1TitOrgaoEstado), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitEndereço}", replacewith:=Nz(Me.Vend1TitEndereço), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitCidade}", replacewith:=Nz(Me.Vend1TitCidade), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitEstado}", replacewith:=Nz(Me.Vend1TitEstado), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitNac}", replacewith:=Nz(Me.Vend1TitNac), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitEstCivil}", replacewith:=Nz(Me.Vend1TitEstCivil), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitProf}", replacewith:=Nz(Me.Vend1TitProf), Format:=True, Replace:=2
.Execute findtext:="{Vend2TitNome}", replacewith:=Me.Vend2TitNome, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitCPF}", replacewith:=Me.Vend2TitCPF, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitIdentidade}", replacewith:=Me.Vend2TitIdentidade, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitOrgaoEstado}", replacewith:=Me.Vend2TitOrgaoEstado, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitEndereço}", replacewith:=Me.Vend2TitEndereço, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitCidade}", replacewith:=Me.Vend2TitCidade, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitEstado}", replacewith:=Me.Vend2TitEstado, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitNac}", replacewith:=Me.Vend2TitNac, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitEstCivil}", replacewith:=Me.Vend2TitEstCivil, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitProf}", replacewith:=Me.Vend2TitProf, Format:=True, Replace:=2
.Execute findtext:="{C1NOME}", replacewith:=Me.C1Nome, Format:=True, Replace:=2
.Execute findtext:="{C1NAC}", replacewith:=Me.C1Nac, Format:=True, Replace:=2
.Execute findtext:="{C1ESTCIVIL}", replacewith:=Me.C1EstCivil, Format:=True, Replace:=2
.Execute findtext:="{C1PROF}", replacewith:=Me.C1Prof, Format:=True, Replace:=2
.Execute findtext:="{C1IDENT}", replacewith:=Me.C1Ident, Format:=True, Replace:=2
.Execute findtext:="{C1ORGAOESTADO}", replacewith:=Me.C1OrgaoEstado, Format:=True, Replace:=2
.Execute findtext:="{C1CPF}", replacewith:=Me.C1Cpf, Format:=True, Replace:=2
.Execute findtext:="{C1END}", replacewith:=Me.C1End, Format:=True, Replace:=2
.Execute findtext:="{C1CIDADE}", replacewith:=Me.C1Cidade, Format:=True, Replace:=2
.Execute findtext:="{C1ESTADO}", replacewith:=Me.C1Estado, Format:=True, Replace:=2
.Execute findtext:="{C1CEP}", replacewith:=Me.C1Cep, Format:=True, Replace:=2
.Execute findtext:="{C1TEL1}", replacewith:=Nz(Me.C1Tel1), Format:=True, Replace:=2
.Execute findtext:="{C1TEL2}", replacewith:=Nz(Me.C1Tel2), Format:=True, Replace:=2
.Execute findtext:="{C1EMAIL}", replacewith:=Nz(Me.C1Email), Format:=True, Replace:=2
.Execute findtext:="{C2NOME}", replacewith:=Nz(Me.C2Nome), Format:=True, Replace:=2
.Execute findtext:="{C2NAC}", replacewith:=Nz(Me.C2Nac), Format:=True, Replace:=2
.Execute findtext:="{C2ESTCIVIL}", replacewith:=Nz(Me.C2EstCivil), Format:=True, Replace:=2
.Execute findtext:="{C2PROF}", replacewith:=Nz(Me.C2Prof), Format:=True, Replace:=2
.Execute findtext:="{C2IDENT}", replacewith:=Nz(Me.C2Ident), Format:=True, Replace:=2
.Execute findtext:="{C2ORGAOESTADO}", replacewith:=Nz(Me.C2OrgaoEstado), Format:=True, Replace:=2
.Execute findtext:="{C2CPF}", replacewith:=Nz(Me.C2Cpf), Format:=True, Replace:=2
.Execute findtext:="{C2END}", replacewith:=Nz(Me.C2End), Format:=True, Replace:=2
.Execute findtext:="{C2CIDADE}", replacewith:=Nz(Me.C2Cidade), Format:=True, Replace:=2
.Execute findtext:="{C2ESTADO}", replacewith:=Nz(Me.C2Estado), Format:=True, Replace:=2
.Execute findtext:="{C2CEP}", replacewith:=Nz(Me.C2Cep), Format:=True, Replace:=2
.Execute findtext:="{C2TEL1}", replacewith:=Nz(Me.C2Tel1), Format:=True, Replace:=2
.Execute findtext:="{C2TEL2}", replacewith:=Nz(Me.C2Tel2), Format:=True, Replace:=2
.Execute findtext:="{C2EMAIL}", replacewith:=Nz(Me.C2Email), Format:=True, Replace:=2
.Execute findtext:="{LOTE}", replacewith:=Me.Lote, Format:=True, Replace:=2
.Execute findtext:="{QUADRA}", replacewith:=Me.Quadra, Format:=True, Replace:=2
.Execute findtext:="{LOGRADOURO}", replacewith:=Me.Logradouro, Format:=True, Replace:=2
.Execute findtext:="{FRENTE}", replacewith:=Me.Frente, Format:=True, Replace:=2
.Execute findtext:="{FUNDOS}", replacewith:=Me.Fundos, Format:=True, Replace:=2
.Execute findtext:="{LADODIREITO}", replacewith:=Me.LadoDireito, Format:=True, Replace:=2
.Execute findtext:="{LADOESQUERDO}", replacewith:=Me.LadoEsquerdo, Format:=True, Replace:=2
.Execute findtext:="{CHANFRO}", replacewith:=Nz(Me.Chanfro), Format:=True, Replace:=2
.Execute findtext:="{DIVFUNDOS}", replacewith:=Me.DivFundos, Format:=True, Replace:=2
.Execute findtext:="{DIVLD}", replacewith:=Me.DivLD, Format:=True, Replace:=2
.Execute findtext:="{DIVLE}", replacewith:=Me.DivLE, Format:=True, Replace:=2
.Execute findtext:="{METRAGEMTOTAL}", replacewith:=Me.MetragemTotal, Format:=True, Replace:=2
.Execute findtext:="{METRAGEMTOTALEXT}", replacewith:=Me.MetragemTotalExt, Format:=True, Replace:=2
.Execute findtext:="{VALORTOTAL}", replacewith:=Me.ValorTotal, Format:=True, Replace:=2
.Execute findtext:="{VALORTOTALEXT}", replacewith:=Me.ValorTotalExt, Format:=True, Replace:=2
.Execute findtext:="{QTDEPARCELA}", replacewith:=Me.QtdeParcelas, Format:=True, Replace:=2
.Execute findtext:="{QTDEPARCELAEXT}", replacewith:=Me.QtdeParcelasExt, Format:=True, Replace:=2
.Execute findtext:="{VALORPARCELA}", replacewith:=Me.ValorParcela, Format:=True, Replace:=2
.Execute findtext:="{VALORPARCELAEXT}", replacewith:=Me.ValorParcExt, Format:=True, Replace:=2
.Execute findtext:="{VENCPARCELA1}", replacewith:=Me.VencParcela1, Format:=True, Replace:=2
.Execute findtext:="{DATACORREÇÃO}", replacewith:=Me.DataCorreção, Format:=True, Replace:=2
EscribeWord (Me.Id)
DoEvents
If MsgBox("Visualizar Contrato " & vbCrLf & Me.NrContrato & "-" & Me.NomeC1, vbExclamation + vbNo, "Confirme") = vbYes Then
AppWord.PrintOut
End If
'DocWord.Open True
Set DocWord = Nothing
End With
AppWord.Quit
Set AppWord = Nothing
End Sub
-----------------------------------------------------------------------------------------------------------------------------------
Obrigado
Ari
Qual código e onde vai para que ao clicar visualizar, abra no Word-Mala Direta apenas o registro que está aberto no Formulário do Access?
Atualmente quando clico em visualizar, abrem todos os Contratos da Mala Direta no Word.
-------------------------------------------------------------------------------------------------------------------------------------------
Private Sub VisualizarContrato_Click()
Dim AppWord As Object, strFinalDoc As String
strFinalDoc = CurrentProject.Path & "\ContratoEncore.docx"
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
Set DocWord = AppWord.Documents.Add(strFinalDoc)
With DocWord.Content.Find
.Execute findtext:="{DATACONTRATO}", replacewith:=DataContrato, Format:=True, Replace:=2
.Execute findtext:="{NRCONTRATO}", replacewith:=Me.NrContrato, Format:=True, Replace:=2
.Execute findtext:="{EMPREENDIMENTO}", replacewith:=Me.Empreendimento, Format:=True, Replace:=2
.Execute findtext:="{Vend1}", replacewith:=Nz(Me.Vend1), Format:=True, Replace:=2
.Execute findtext:="{Vend1CNPJ}", replacewith:=Nz(Me.Vend1CNPJ), Format:=True, Replace:=2
.Execute findtext:="{Vend1End}", replacewith:=Nz(Me.Vend1End), Format:=True, Replace:=2
.Execute findtext:="{Vend1Cidade}", replacewith:=Nz(Me.Vend1Cidade), Format:=True, Replace:=2
.Execute findtext:="{Vend1Estado}", replacewith:=Nz(Me.Vend1Estado), Format:=True, Replace:=2
.Execute findtext:="{Vend2}", replacewith:=Nz(Me.Vend2), Format:=True, Replace:=2
.Execute findtext:="{Vend2CNPJ}", replacewith:=Nz(Me.Vend2CNPJ), Format:=True, Replace:=2
.Execute findtext:="{Vend2End}", replacewith:=Nz(Me.Vend2End), Format:=True, Replace:=2
.Execute findtext:="{Vend2Cidade}", replacewith:=Nz(Me.Vend2Cidade), Format:=True, Replace:=2
.Execute findtext:="{Vend2Estado}", replacewith:=Nz(Me.Vend2Estado), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitNome}", replacewith:=Nz(Me.Vend1TitNome), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitCPF}", replacewith:=Nz(Me.Vend1TitCPF), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitIdentidade}", replacewith:=Nz(Me.Vend1TitIdentidade), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitOrgaoEstado}", replacewith:=Nz(Me.Vend1TitOrgaoEstado), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitEndereço}", replacewith:=Nz(Me.Vend1TitEndereço), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitCidade}", replacewith:=Nz(Me.Vend1TitCidade), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitEstado}", replacewith:=Nz(Me.Vend1TitEstado), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitNac}", replacewith:=Nz(Me.Vend1TitNac), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitEstCivil}", replacewith:=Nz(Me.Vend1TitEstCivil), Format:=True, Replace:=2
.Execute findtext:="{Vend1TitProf}", replacewith:=Nz(Me.Vend1TitProf), Format:=True, Replace:=2
.Execute findtext:="{Vend2TitNome}", replacewith:=Me.Vend2TitNome, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitCPF}", replacewith:=Me.Vend2TitCPF, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitIdentidade}", replacewith:=Me.Vend2TitIdentidade, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitOrgaoEstado}", replacewith:=Me.Vend2TitOrgaoEstado, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitEndereço}", replacewith:=Me.Vend2TitEndereço, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitCidade}", replacewith:=Me.Vend2TitCidade, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitEstado}", replacewith:=Me.Vend2TitEstado, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitNac}", replacewith:=Me.Vend2TitNac, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitEstCivil}", replacewith:=Me.Vend2TitEstCivil, Format:=True, Replace:=2
.Execute findtext:="{Vend2TitProf}", replacewith:=Me.Vend2TitProf, Format:=True, Replace:=2
.Execute findtext:="{C1NOME}", replacewith:=Me.C1Nome, Format:=True, Replace:=2
.Execute findtext:="{C1NAC}", replacewith:=Me.C1Nac, Format:=True, Replace:=2
.Execute findtext:="{C1ESTCIVIL}", replacewith:=Me.C1EstCivil, Format:=True, Replace:=2
.Execute findtext:="{C1PROF}", replacewith:=Me.C1Prof, Format:=True, Replace:=2
.Execute findtext:="{C1IDENT}", replacewith:=Me.C1Ident, Format:=True, Replace:=2
.Execute findtext:="{C1ORGAOESTADO}", replacewith:=Me.C1OrgaoEstado, Format:=True, Replace:=2
.Execute findtext:="{C1CPF}", replacewith:=Me.C1Cpf, Format:=True, Replace:=2
.Execute findtext:="{C1END}", replacewith:=Me.C1End, Format:=True, Replace:=2
.Execute findtext:="{C1CIDADE}", replacewith:=Me.C1Cidade, Format:=True, Replace:=2
.Execute findtext:="{C1ESTADO}", replacewith:=Me.C1Estado, Format:=True, Replace:=2
.Execute findtext:="{C1CEP}", replacewith:=Me.C1Cep, Format:=True, Replace:=2
.Execute findtext:="{C1TEL1}", replacewith:=Nz(Me.C1Tel1), Format:=True, Replace:=2
.Execute findtext:="{C1TEL2}", replacewith:=Nz(Me.C1Tel2), Format:=True, Replace:=2
.Execute findtext:="{C1EMAIL}", replacewith:=Nz(Me.C1Email), Format:=True, Replace:=2
.Execute findtext:="{C2NOME}", replacewith:=Nz(Me.C2Nome), Format:=True, Replace:=2
.Execute findtext:="{C2NAC}", replacewith:=Nz(Me.C2Nac), Format:=True, Replace:=2
.Execute findtext:="{C2ESTCIVIL}", replacewith:=Nz(Me.C2EstCivil), Format:=True, Replace:=2
.Execute findtext:="{C2PROF}", replacewith:=Nz(Me.C2Prof), Format:=True, Replace:=2
.Execute findtext:="{C2IDENT}", replacewith:=Nz(Me.C2Ident), Format:=True, Replace:=2
.Execute findtext:="{C2ORGAOESTADO}", replacewith:=Nz(Me.C2OrgaoEstado), Format:=True, Replace:=2
.Execute findtext:="{C2CPF}", replacewith:=Nz(Me.C2Cpf), Format:=True, Replace:=2
.Execute findtext:="{C2END}", replacewith:=Nz(Me.C2End), Format:=True, Replace:=2
.Execute findtext:="{C2CIDADE}", replacewith:=Nz(Me.C2Cidade), Format:=True, Replace:=2
.Execute findtext:="{C2ESTADO}", replacewith:=Nz(Me.C2Estado), Format:=True, Replace:=2
.Execute findtext:="{C2CEP}", replacewith:=Nz(Me.C2Cep), Format:=True, Replace:=2
.Execute findtext:="{C2TEL1}", replacewith:=Nz(Me.C2Tel1), Format:=True, Replace:=2
.Execute findtext:="{C2TEL2}", replacewith:=Nz(Me.C2Tel2), Format:=True, Replace:=2
.Execute findtext:="{C2EMAIL}", replacewith:=Nz(Me.C2Email), Format:=True, Replace:=2
.Execute findtext:="{LOTE}", replacewith:=Me.Lote, Format:=True, Replace:=2
.Execute findtext:="{QUADRA}", replacewith:=Me.Quadra, Format:=True, Replace:=2
.Execute findtext:="{LOGRADOURO}", replacewith:=Me.Logradouro, Format:=True, Replace:=2
.Execute findtext:="{FRENTE}", replacewith:=Me.Frente, Format:=True, Replace:=2
.Execute findtext:="{FUNDOS}", replacewith:=Me.Fundos, Format:=True, Replace:=2
.Execute findtext:="{LADODIREITO}", replacewith:=Me.LadoDireito, Format:=True, Replace:=2
.Execute findtext:="{LADOESQUERDO}", replacewith:=Me.LadoEsquerdo, Format:=True, Replace:=2
.Execute findtext:="{CHANFRO}", replacewith:=Nz(Me.Chanfro), Format:=True, Replace:=2
.Execute findtext:="{DIVFUNDOS}", replacewith:=Me.DivFundos, Format:=True, Replace:=2
.Execute findtext:="{DIVLD}", replacewith:=Me.DivLD, Format:=True, Replace:=2
.Execute findtext:="{DIVLE}", replacewith:=Me.DivLE, Format:=True, Replace:=2
.Execute findtext:="{METRAGEMTOTAL}", replacewith:=Me.MetragemTotal, Format:=True, Replace:=2
.Execute findtext:="{METRAGEMTOTALEXT}", replacewith:=Me.MetragemTotalExt, Format:=True, Replace:=2
.Execute findtext:="{VALORTOTAL}", replacewith:=Me.ValorTotal, Format:=True, Replace:=2
.Execute findtext:="{VALORTOTALEXT}", replacewith:=Me.ValorTotalExt, Format:=True, Replace:=2
.Execute findtext:="{QTDEPARCELA}", replacewith:=Me.QtdeParcelas, Format:=True, Replace:=2
.Execute findtext:="{QTDEPARCELAEXT}", replacewith:=Me.QtdeParcelasExt, Format:=True, Replace:=2
.Execute findtext:="{VALORPARCELA}", replacewith:=Me.ValorParcela, Format:=True, Replace:=2
.Execute findtext:="{VALORPARCELAEXT}", replacewith:=Me.ValorParcExt, Format:=True, Replace:=2
.Execute findtext:="{VENCPARCELA1}", replacewith:=Me.VencParcela1, Format:=True, Replace:=2
.Execute findtext:="{DATACORREÇÃO}", replacewith:=Me.DataCorreção, Format:=True, Replace:=2
EscribeWord (Me.Id)
DoEvents
If MsgBox("Visualizar Contrato " & vbCrLf & Me.NrContrato & "-" & Me.NomeC1, vbExclamation + vbNo, "Confirme") = vbYes Then
AppWord.PrintOut
End If
'DocWord.Open True
Set DocWord = Nothing
End With
AppWord.Quit
Set AppWord = Nothing
End Sub
-----------------------------------------------------------------------------------------------------------------------------------
Obrigado
Ari