Private Sub cmd_gerar_contrato_Click()netocasaroli escreveu:Poste seu código aqui para darmos uma olhada mais detalhada.
'--------------CODIGOS QUE FAZER A COMUNICAÇÃO E CONEXAO COM O WORD----------------------------------------
'Todos esses comando abaixo sao fundamentais para a comunicação do Excel com o Word
Dim Nome As String
Nome = txt_nome.Text 'Aqui vai o nome do campo que deseja das destaque
Static wd1 As Word.Application '
Static wd1Doc As Word.Document ' Esses codigos sao os principais para carregar o documento novo do Word
Set wd1 = New Word.Application '
wd1.Visible = True '
Set wd1Doc = wd1.Documents.Add(ThisWorkbook.Path & "\contrato_modelo.docx") '
'------------------------------------------------------------------------------------------------------------
'-------------AQUI VAI OS CODIGOS QUE SUBISTITUI OS CAMPOS DO WORD PELOS CAMPOS DESEJADOS DO EXCEL-----------
With wd1Doc
'ESSES PRIMEROS COD. FAZEM A FORMATAÇÃO E TRAS OS DADOS COMO NEGRITO
.FormFields("WContratante").Range.Font.Bold = True
.FormFields("WCnpj_CPF_contratant").Range.Font.Bold = True
.FormFields("WIE_RG_contratante").Range.Font.Bold = True
.FormFields("WTipo_construcao").Range.Font.Bold = True
.FormFields("WTamanho").Range.Font.Bold = True
.FormFields("WQuadra").Range.Font.Bold = True
.FormFields("WLote").Range.Font.Bold = True
.FormFields("WBairro").Range.Font.Bold = True
.FormFields("WArea_total").Range.Font.Bold = True
.FormFields("WValor_Total").Range.Font.Bold = True
.FormFields("WValor_Total_Extenso").Range.Font.Bold = True
.FormFields("WValor_Parcela").Range.Font.Bold = True
.FormFields("WValor_Parcela_Esten").Range.Font.Bold = True
.FormFields("WMontante_total").Range.Font.Bold = True
.FormFields("WMontante_total_espr").Range.Font.Bold = True
.FormFields("WParcela").Range.Font.Bold = True
.FormFields("WMelhor_dia").Range.Font.Bold = True
.FormFields("WCidade_data").Range.Font.Bold = True
'1ºParte
.FormFields("WContratante").Range = txt_nome.Text
.FormFields("WEstado_civil").Range = txt_estado_civil.Text
.FormFields("WCnpj_CPF_contratant").Range = txt_cpf_cnpj
.FormFields("WIE_RG_contratante").Range = txt_rg_ie
.FormFields("WCidade").Range = txt_cidade.Text
.FormFields("WUF").Range = combo_uf.Text
'2º Parte
.FormFields("WTipo_construcao").Range = combo_tipo_endereco.Text
.FormFields("WTamanho").Range = txt_area_construcao.Text
.FormFields("WQuadra").Range = txt_quadra
.FormFields("WLote").Range = txt_lote
.FormFields("WBairro").Range = txt_bairro.Text
.FormFields("WArea_total").Range = txt_area_terreno
'3ºParte Valores
.FormFields("WValor_Total").Range = txt_valor
.FormFields("WValor_Total_Extenso").Range = txt_valor_metro_extenso.Text
.FormFields("WParcela").Range = txt_num_parcela / 1
.FormFields("WValor_Parcela").Range = txt_valor_parcela
.FormFields("WValor_Parcela_Esten").Range = txt_valor_parcela_extenso.Text
.FormFields("WMontante_total").Range = txt_valor_total
.FormFields("WMontante_total_espr").Range = txt_valor_total_extenso.Text
.FormFields("WMelhor_dia").Range = txt_dia_venc
'4º Parte Data
.FormFields("WCidade_data").Range = txt_cidade.Text
.FormFields("WContratante").Range = txt_nome.Text
.FormFields("WCPF_contratante").Range = txt_cpf_cnpj
'-------------AQUI VAI OS CODIGOS PARA SALVAR O DOC DO WORD COM O NOME DO CLIENTE QUE ESTIVER ESCRITO NO TXTNOME------
'POR ISSO QUE FOI DECLARADO A VARIAVEL NOME, PARA QUE O DOC CARREGUE O VALOR CONTIDO NA VARIAVEL--------------
' ChDrive ActiveDocument.Path
' ChangeFileOpenDirectory "C:\Users\Maicon Brigido\Desktop\Programa\contrato"
' ActiveDocument.SaveAs ("CONTRATO " & Nome)
.SaveAs2 "ThisWorkbook.Path" & "\CONTRATO " & Nome 'aqui deve altera o caminho
'ChDir ThisWorkbook.Path & "\contrato"
'.SaveAs2 ThisWorkbook.Path & "\CONTRATO " & Nome
End With
End Sub