title: Creating Word document from Excel through VBA
body: <p>Folks. I have an Excel file and want to create a Word document with the data in a sheet. The program shows an error and I can't find the reason.</p>
  
  <p>I tried to use the following code:</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  ' Objetos Word
    Dim obj1 As New Application
    Dim wdDoc As Word.Document
  
  ' Objetos Excel
    Dim wbBook As Workbook
    Dim wsSheet As Worksheet
  
    Dim Caminho, Arquivo, Nome_aluno, Ender As String
    Dim Gen_p, Gen_a, Hora, Prof, Resp As String
    Dim i, Comp As Integer
    Dim Coord_C As Integer
    Dim Coord_L As Integer
    Caminho = "D:\Data\Office\Excel\"
    Arquivo = "Anexo D - Ata de defesa TCC.docx"
  </code></pre>
  
  <p>The code continues, but is irrelevant for now.
  The point is when I run the code I get the message:</p>
  
  <blockquote>
    <p>User defined type not defined</p>
  </blockquote>
  
  <p>This is weird, because in another Excel file I can run it, and it works fine.
  What have I missed? Do I have to link something?</p>