I'm trying do generate some files docx of data from excel to word. I'm just learning the basic of VBA, so I lasted a few hours to find this a find and replace logical. But at the time I tried with a lot of text, more than 255 characteres it's not worked well.
Maybe you can find some simple solution. This is the code abelow:
Sub gera_plano()
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set arqPlanos = objWord.Documents.Open(ThisWorkbook.Path & "\Modelo de Plano de Aula
(macro).docx")
Set conteudoDoc = arqPlanos.Application.Selection
For colTab = 1 To 20
conteudoDoc.Find.Text = Cells(1, colTab).Value
conteudoDoc.Find.Replacement.Text = Cells(2, colTab).Value
conteudoDoc.Find.Execute Replace:=wdReplaceAll
Next
arqPlanos.SaveAs2 (ThisWorkbook.Path & "\Planos\Aula - " & Cells(2, 3).Value & " -T" & Cells(2,
1).Value & ".docx")
arqPlanos.Close
objWord.Quit
Set arqPlanos = Nothing
Set conteudoDoc = Nothing
Set objWord = Nothing
MsgBox ("Plano gerado com sucesso!")
End Sub
Thank you very much for your helop