Hello all,
my code is modified from the thread below.
http://www.ozgrid.com/forum/showthread.php?t=19401
Code
Sub createWordReport()
On Error GoTo errorHandler
Dim wdApp As Word.Application
Dim myDoc As Word.Document
Dim mywdRange As Word.Range
Dim Fname As Excel.Range
Dim Mname As Excel.Range
Dim Lname As Excel.Range
With wdApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set myDoc = "C:\Documents and Settings\User\My Documents\test.doc"
Set Fname = Sheets("testing").Range("A1")
Set Mname = Sheets("testing").Range("A2")
Set Lname = Sheets("testing").Range("A2")
With myDoc.Bookmarks
.Item("Fname").Range.InsertAfter First
.Item("Mname").Range.InsertAfter Mid
.Item("Lname").Range.InsertAfter LAst
End With
errorHandler:
Set wdApp = Nothing
Set myDoc = Nothing
Set mywdRange = Nothing
End Sub
Display More
I already have the word like created and the bookmarks added.
I recieve an error "User defined type not defined" on this line.
I have a word document created with bookmarks (First, Mid, Last) in it already
Ive tried it with my word file open as well as closed and still no luck.
Anyone have any ideas?
Thanks,
Ross