Peguei um exemplo aqui no fórum muito bom mais ao mandar para o Word ele só imprime se estiver preenchido o campo eu quero que ele imprimir os campos em branco também. Outra coisa que ele visualize o doc antes de imprimir.
O que quero e imprimir os campos fazios também só isso!
Private Sub CmdImprime_Click()
Dim AppWord As Object, strFinalDoc As String
strFinalDoc = CurrentProject.PATH & "\fichahabitacao.rtf"
'referencio implictamente para evitar problemas de referencias
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = False
Set DocWord = AppWord.Documents.Add(strFinalDoc)
'**********************MARCA******************************************************
'Estos son los códigos que debo reemplazar en cada pasada
'{FECHA} pues la fecha del sistema
'{NOMBRECLIENTE} el nombre del cliente
'{DIRECCION}
'{CIUDAD}
With DocWord.Content.Find
.Execute findtext:="{CPF}", replacewith:=Me.CPF, Format:=True, Replace:=2
.Execute findtext:="{NOMECLIENTE}", replacewith:=Me.NOMECLIENTE, Format:=True, Replace:=2
.Execute findtext:="{DATADENASCIMENTO}", replacewith:=Me.DATADENASCIMENTO, Format:=True, Replace:=2
.Execute findtext:="{cidNATURALIDADE}", replacewith:=Me.cidNATURALIDADE, Format:=True, Replace:=2
.Execute findtext:="{cidUF}", replacewith:=Me.cidUF, Format:=True, Replace:=2
.Execute findtext:="{NOMEDOPAI}", replacewith:=Me.NOMEDOPAI, Format:=True, Replace:=2
.Execute findtext:="{NOMEDAMAE}", replacewith:=Me.NOMEDAMAE, Format:=True, Replace:=2
.Execute findtext:="{RG}", replacewith:=Me.RG, Format:=True, Replace:=2
.Execute findtext:="{ORGAOEMISSOR}", replacewith:=Me.ORGAOEMISSOR, Format:=True, Replace:=2
.Execute findtext:="{UF1}", replacewith:=Me.UF1, Format:=True, Replace:=2
.Execute findtext:="{DATAEMISSAO}", replacewith:=Me.DATAEMISSAO, Format:=True, Replace:=2
.Execute findtext:="{CPFCJ}", replacewith:=Me.CPFCJ, Format:=True, Replace:=2
.Execute findtext:="{CONJNASCIMENTO}", replacewith:=Me.CONJNASCIMENTO, Format:=True, Replace:=2
.Execute findtext:="{CEP}", replacewith:=Me.CEP, Format:=True, Replace:=2
.Execute findtext:="{ENDEREÇO}", replacewith:=Me.ENDEREÇO, Format:=True, Replace:=2
.Execute findtext:="{NO}", replacewith:=Me.NO, Format:=True, Replace:=2
.Execute findtext:="{PONTODEREFERÊNCIA}", replacewith:=Me.PONTODEREFERÊNCIA, Format:=True, Replace:=2
.Execute findtext:="{BAIRRO}", replacewith:=Me.BAIRRO, Format:=True, Replace:=2
.Execute findtext:="{UF}", replacewith:=Me.UF, Format:=True, Replace:=2
.Execute findtext:="{CIDADE}", replacewith:=Me.CIDADE, Format:=True, Replace:=2
.Execute findtext:="{TELCEL}", replacewith:=Me.TELCEL, Format:=True, Replace:=2
.Execute findtext:="{TELRES}", replacewith:=Me.TELRES, Format:=True, Replace:=2
.Execute findtext:="{TELRECADOS}", replacewith:=Me.TELRECADOS, Format:=True, Replace:=2
.Execute findtext:="{EMAIL}", replacewith:=Me.EMAIL, Format:=True, Replace:=2
.Execute findtext:="{CNPJCPFPAGADORA}", replacewith:=Me.CNPJCPFPAGADORA, Format:=True, Replace:=2
.Execute findtext:="{NONEFONTPG}", replacewith:=Me.NONEFONTPG, Format:=True, Replace:=2
.Execute findtext:="{CEP2}", replacewith:=Me.CEP2, Format:=True, Replace:=2
.Execute findtext:="{ENDERECORD}", replacewith:=Me.ENDERECORD, Format:=True, Replace:=2
.Execute findtext:="{COMPLEMENTO}", replacewith:=Me.COMPLEMENTO, Format:=True, Replace:=2
.Execute findtext:="{BAIRRORD}", replacewith:=Me.BAIRRORD, Format:=True, Replace:=2
.Execute findtext:="{UFFTPG}", replacewith:=Me.UFFTPG, Format:=True, Replace:=2
.Execute findtext:="{CIDADERD}", replacewith:=Me.CIDADERD, Format:=True, Replace:=2
.Execute findtext:="{TELCOMERCIAL}", replacewith:=Me.TELCOMERCIAL, Format:=True, Replace:=2
.Execute findtext:="{{FAXCOMERCIAL}", replacewith:=Me.FAXCOMERCIAL, Format:=True, Replace:=2
.Execute findtext:="{RENDACODIR}", replacewith:=Me.RENDACODIR, Format:=True, Replace:=2
.Execute findtext:="{DESCRICAOOCUPACAO}", replacewith:=Me.DESCRICAOOCUPACAO, Format:=True, Replace:=2
.Execute findtext:="{DTINICIORENDA}", replacewith:=Me.DTINICIORENDA, Format:=True, Replace:=2
.Execute findtext:="{CARGOFUNCAO}", replacewith:=Me.CARGOFUNCAO, Format:=True, Replace:=2
.Execute findtext:="{RENDABRUTA}", replacewith:=Me.RENDABRUTA, Format:=True, Replace:=2
.Execute findtext:="{RENDALIQUIDA}", replacewith:=Me.RENDALIQUIDA, Format:=True, Replace:=2
.Execute findtext:="{CNPJCPFPAGADORA2}", replacewith:=Me.CNPJCPFPAGADORA2, Format:=True, Replace:=2
.Execute findtext:="{NONEFONTPG2}", replacewith:=Me.NONEFONTPG2, Format:=True, Replace:=2
.Execute findtext:="{CEP3}", replacewith:=Me.CEP3, Format:=True, Replace:=2
.Execute findtext:="{ENDERECORD2}", replacewith:=Me.ENDERECORD, Format:=True, Replace:=2
.Execute findtext:="{COMPLEMENTO2}", replacewith:=Me.COMPLEMENTO, Format:=True, Replace:=2
.Execute findtext:="{BAIRRORD2}", replacewith:=Me.BAIRRORD, Format:=True, Replace:=2
.Execute findtext:="{UFFTPG2}", replacewith:=Me.UFFTPG, Format:=True, Replace:=2
.Execute findtext:="{CIDADERD2}", replacewith:=Me.CIDADERD2, Format:=True, Replace:=2
.Execute findtext:="{TELCOMERCIAL2}", replacewith:=Me.TELCOMERCIAL2, Format:=True, Replace:=2
.Execute findtext:="{{FAXCOMERCIAL2}", replacewith:=Me.FAXCOMERCIAL2, Format:=True, Replace:=2
.Execute findtext:="{RENDACODIR2}", replacewith:=Me.RENDACODIR2, Format:=True, Replace:=2
.Execute findtext:="{DESCRICAOOCUPACAO2}", replacewith:=Me.DESCRICAOOCUPACAO2, Format:=True, Replace:=2
.Execute findtext:="{DTINICIORENDA2}", replacewith:=Me.DTINICIORENDA2, Format:=True, Replace:=2
.Execute findtext:="{CARGOFUNCAO2}", replacewith:=Me.CARGOFUNCAO2, Format:=True, Replace:=2
.Execute findtext:="{RENDABRUTA2}", replacewith:=Me.RENDABRUTA2, Format:=True, Replace:=2
.Execute findtext:="{RENDALIQUIDA2}", replacewith:=Me.RENDALIQUIDA2, Format:=True, Replace:=2
'********************* FIN DE MARCA **************************************************
'===============================
EscribeWord
'===============================
DoEvents
'Tienes que probar si para muchos clientes, el codigo se
'comporta bien, por si se llena el Buffer de la Impresora
'======Aqui la orden de impresión de la carta. La quito para no gastar papel
'-----------------
If MsgBox("Imprimir a ficha " & vbCrLf & Me.NOMECLIENTE, vbExclamation + vbYesNo, "Confirme") = vbYes Then
AppWord.PrintOut
End If
'-----------------
'======Fin de la orden de impresión
'destruyo este dodumento concreto del cliente una vez imprimido
DocWord.Close False
Set DocWord = Nothing
End With
'destruyo la variable
AppWord.Quit
Set AppWord = Nothing
End Sub
O que quero e imprimir os campos fazios também só isso!
Private Sub CmdImprime_Click()
Dim AppWord As Object, strFinalDoc As String
strFinalDoc = CurrentProject.PATH & "\fichahabitacao.rtf"
'referencio implictamente para evitar problemas de referencias
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = False
Set DocWord = AppWord.Documents.Add(strFinalDoc)
'**********************MARCA******************************************************
'Estos son los códigos que debo reemplazar en cada pasada
'{FECHA} pues la fecha del sistema
'{NOMBRECLIENTE} el nombre del cliente
'{DIRECCION}
'{CIUDAD}
With DocWord.Content.Find
.Execute findtext:="{CPF}", replacewith:=Me.CPF, Format:=True, Replace:=2
.Execute findtext:="{NOMECLIENTE}", replacewith:=Me.NOMECLIENTE, Format:=True, Replace:=2
.Execute findtext:="{DATADENASCIMENTO}", replacewith:=Me.DATADENASCIMENTO, Format:=True, Replace:=2
.Execute findtext:="{cidNATURALIDADE}", replacewith:=Me.cidNATURALIDADE, Format:=True, Replace:=2
.Execute findtext:="{cidUF}", replacewith:=Me.cidUF, Format:=True, Replace:=2
.Execute findtext:="{NOMEDOPAI}", replacewith:=Me.NOMEDOPAI, Format:=True, Replace:=2
.Execute findtext:="{NOMEDAMAE}", replacewith:=Me.NOMEDAMAE, Format:=True, Replace:=2
.Execute findtext:="{RG}", replacewith:=Me.RG, Format:=True, Replace:=2
.Execute findtext:="{ORGAOEMISSOR}", replacewith:=Me.ORGAOEMISSOR, Format:=True, Replace:=2
.Execute findtext:="{UF1}", replacewith:=Me.UF1, Format:=True, Replace:=2
.Execute findtext:="{DATAEMISSAO}", replacewith:=Me.DATAEMISSAO, Format:=True, Replace:=2
.Execute findtext:="{CPFCJ}", replacewith:=Me.CPFCJ, Format:=True, Replace:=2
.Execute findtext:="{CONJNASCIMENTO}", replacewith:=Me.CONJNASCIMENTO, Format:=True, Replace:=2
.Execute findtext:="{CEP}", replacewith:=Me.CEP, Format:=True, Replace:=2
.Execute findtext:="{ENDEREÇO}", replacewith:=Me.ENDEREÇO, Format:=True, Replace:=2
.Execute findtext:="{NO}", replacewith:=Me.NO, Format:=True, Replace:=2
.Execute findtext:="{PONTODEREFERÊNCIA}", replacewith:=Me.PONTODEREFERÊNCIA, Format:=True, Replace:=2
.Execute findtext:="{BAIRRO}", replacewith:=Me.BAIRRO, Format:=True, Replace:=2
.Execute findtext:="{UF}", replacewith:=Me.UF, Format:=True, Replace:=2
.Execute findtext:="{CIDADE}", replacewith:=Me.CIDADE, Format:=True, Replace:=2
.Execute findtext:="{TELCEL}", replacewith:=Me.TELCEL, Format:=True, Replace:=2
.Execute findtext:="{TELRES}", replacewith:=Me.TELRES, Format:=True, Replace:=2
.Execute findtext:="{TELRECADOS}", replacewith:=Me.TELRECADOS, Format:=True, Replace:=2
.Execute findtext:="{EMAIL}", replacewith:=Me.EMAIL, Format:=True, Replace:=2
.Execute findtext:="{CNPJCPFPAGADORA}", replacewith:=Me.CNPJCPFPAGADORA, Format:=True, Replace:=2
.Execute findtext:="{NONEFONTPG}", replacewith:=Me.NONEFONTPG, Format:=True, Replace:=2
.Execute findtext:="{CEP2}", replacewith:=Me.CEP2, Format:=True, Replace:=2
.Execute findtext:="{ENDERECORD}", replacewith:=Me.ENDERECORD, Format:=True, Replace:=2
.Execute findtext:="{COMPLEMENTO}", replacewith:=Me.COMPLEMENTO, Format:=True, Replace:=2
.Execute findtext:="{BAIRRORD}", replacewith:=Me.BAIRRORD, Format:=True, Replace:=2
.Execute findtext:="{UFFTPG}", replacewith:=Me.UFFTPG, Format:=True, Replace:=2
.Execute findtext:="{CIDADERD}", replacewith:=Me.CIDADERD, Format:=True, Replace:=2
.Execute findtext:="{TELCOMERCIAL}", replacewith:=Me.TELCOMERCIAL, Format:=True, Replace:=2
.Execute findtext:="{{FAXCOMERCIAL}", replacewith:=Me.FAXCOMERCIAL, Format:=True, Replace:=2
.Execute findtext:="{RENDACODIR}", replacewith:=Me.RENDACODIR, Format:=True, Replace:=2
.Execute findtext:="{DESCRICAOOCUPACAO}", replacewith:=Me.DESCRICAOOCUPACAO, Format:=True, Replace:=2
.Execute findtext:="{DTINICIORENDA}", replacewith:=Me.DTINICIORENDA, Format:=True, Replace:=2
.Execute findtext:="{CARGOFUNCAO}", replacewith:=Me.CARGOFUNCAO, Format:=True, Replace:=2
.Execute findtext:="{RENDABRUTA}", replacewith:=Me.RENDABRUTA, Format:=True, Replace:=2
.Execute findtext:="{RENDALIQUIDA}", replacewith:=Me.RENDALIQUIDA, Format:=True, Replace:=2
.Execute findtext:="{CNPJCPFPAGADORA2}", replacewith:=Me.CNPJCPFPAGADORA2, Format:=True, Replace:=2
.Execute findtext:="{NONEFONTPG2}", replacewith:=Me.NONEFONTPG2, Format:=True, Replace:=2
.Execute findtext:="{CEP3}", replacewith:=Me.CEP3, Format:=True, Replace:=2
.Execute findtext:="{ENDERECORD2}", replacewith:=Me.ENDERECORD, Format:=True, Replace:=2
.Execute findtext:="{COMPLEMENTO2}", replacewith:=Me.COMPLEMENTO, Format:=True, Replace:=2
.Execute findtext:="{BAIRRORD2}", replacewith:=Me.BAIRRORD, Format:=True, Replace:=2
.Execute findtext:="{UFFTPG2}", replacewith:=Me.UFFTPG, Format:=True, Replace:=2
.Execute findtext:="{CIDADERD2}", replacewith:=Me.CIDADERD2, Format:=True, Replace:=2
.Execute findtext:="{TELCOMERCIAL2}", replacewith:=Me.TELCOMERCIAL2, Format:=True, Replace:=2
.Execute findtext:="{{FAXCOMERCIAL2}", replacewith:=Me.FAXCOMERCIAL2, Format:=True, Replace:=2
.Execute findtext:="{RENDACODIR2}", replacewith:=Me.RENDACODIR2, Format:=True, Replace:=2
.Execute findtext:="{DESCRICAOOCUPACAO2}", replacewith:=Me.DESCRICAOOCUPACAO2, Format:=True, Replace:=2
.Execute findtext:="{DTINICIORENDA2}", replacewith:=Me.DTINICIORENDA2, Format:=True, Replace:=2
.Execute findtext:="{CARGOFUNCAO2}", replacewith:=Me.CARGOFUNCAO2, Format:=True, Replace:=2
.Execute findtext:="{RENDABRUTA2}", replacewith:=Me.RENDABRUTA2, Format:=True, Replace:=2
.Execute findtext:="{RENDALIQUIDA2}", replacewith:=Me.RENDALIQUIDA2, Format:=True, Replace:=2
'********************* FIN DE MARCA **************************************************
'===============================
EscribeWord
'===============================
DoEvents
'Tienes que probar si para muchos clientes, el codigo se
'comporta bien, por si se llena el Buffer de la Impresora
'======Aqui la orden de impresión de la carta. La quito para no gastar papel
'-----------------
If MsgBox("Imprimir a ficha " & vbCrLf & Me.NOMECLIENTE, vbExclamation + vbYesNo, "Confirme") = vbYes Then
AppWord.PrintOut
End If
'-----------------
'======Fin de la orden de impresión
'destruyo este dodumento concreto del cliente una vez imprimido
DocWord.Close False
Set DocWord = Nothing
End With
'destruyo la variable
AppWord.Quit
Set AppWord = Nothing
End Sub