I am having problems attempting to insert data, gathered from an Excel 2003 SP3 workbook, into an MS Word document.
The macro gathers the information satisfactorily but fails on the first line of the following code, which results in a "Compile error: User defined type not defined", with the first line highlighted.
[code/]Dim appWord As Word.Application
Dim aDoc As Word.Document
Set appWord = CreateObject("Word.Application")
Set aDoc = appWord.Documents.Open(Filename:="c:\test.doc")
aDoc.Application.Visible = True
aDoc.Bookmarks("A").Range.Text = text_a
aDoc.Bookmarks("B").Range.Text = text_b
aDoc.SaveAs (Filename:="c:\" & text_a & ".doc")
aDoc.Close
Set aDoc = Nothing
appWord.Quit
Set appWord = Nothing [/code]
The macro gathers the information satisfactorily but fails on the first line of the following code, which results in a "Compile error: User defined type not defined", with the first line highlighted.
[code/]Dim appWord As Word.Application
Dim aDoc As Word.Document
Set appWord = CreateObject("Word.Application")
Set aDoc = appWord.Documents.Open(Filename:="c:\test.doc")
aDoc.Application.Visible = True
aDoc.Bookmarks("A").Range.Text = text_a
aDoc.Bookmarks("B").Range.Text = text_b
aDoc.SaveAs (Filename:="c:\" & text_a & ".doc")
aDoc.Close
Set aDoc = Nothing
appWord.Quit
Set appWord = Nothing [/code]