I have been using this macro for a while now and now it will not work. I think it has something to do with and update that I have installed but I am not sure. I keep getting invalid syntax error. At Set oWord = GetObject(, "Word.Application") I have no idea what is going on any help would be great.
Code:
Dim oWord As Word.Application
Dim WordWasNotRunning As Boolean
Dim oDoc As Word.Document
Dim myDialog As Word.Dialog
Dim UserButton As Long
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err Then
Set oWord = New Word.Application
WordWasNotRunning = True
End If
On Error GoTo Err_Handler
oWord.Visible = True
oWord.Activate
Set oDoc = oWord.Documents.Add("C:\Macros\Letter1 (Macro).dot")
oDoc.Bookmarks("Line1").Range.InsertBefore rname
oDoc.Bookmarks("Line2").Range.InsertBefore madd1
oDoc.Bookmarks("Line3").Range.InsertBefore madd2
oDoc.Bookmarks("Line5").Range.InsertBefore padd1 & " " & padd2
oDoc.Bookmarks("Line6").Range.InsertBefore npmt
oDoc.Bookmarks("Line7").Range.InsertBefore nduedate
oDoc.Bookmarks("Line10").Range.InsertBefore effdate
oDoc.Bookmarks("Line13").Range.InsertBefore remterm
oDoc.Bookmarks("Line14").Range.InsertBefore matdate
oDoc.Bookmarks("Line15").Range.InsertBefore effdate
oDoc.Bookmarks("Line16").Range.InsertBefore capint
oDoc.Bookmarks("Line17").Range.InsertBefore effdate
oDoc.Bookmarks("Line18").Range.InsertBefore capesc
oDoc.Bookmarks("Line19").Range.InsertBefore npmt
oDoc.Bookmarks("Line20").Range.InsertBefore nduedate
oDoc.Bookmarks("Line22").Range.InsertBefore mextn
oDoc.Bookmarks("Line23").Range.InsertBefore epmt
oDoc.Bookmarks("Line24").Range.InsertBefore workby
oDoc.Bookmarks("Line25").Range.InsertBefore workby
With oDoc
' .PrintOut
.SaveAs "C:\Letters\" & clsavename
' .Close
End With