Hi All
I have used the below code to open existing word doc and link the data from excel to bookmarks in the word doc. When I turned on my computer this morning, opened the workbook and clicked the button it worked perfectly, however when I selected it again it didn't work.
Now it tries to open up a blank word doc, and brings up Run-time error '-2146959355 (80080005)' and the debugger is stopping at this line;
Please help me fix this!!!
I have used the below code to open existing word doc and link the data from excel to bookmarks in the word doc. When I turned on my computer this morning, opened the workbook and clicked the button it worked perfectly, however when I selected it again it didn't work.
Now it tries to open up a blank word doc, and brings up Run-time error '-2146959355 (80080005)' and the debugger is stopping at this line;
Code:
Set objWord = CreateObject("Word.Application")
Please help me fix this!!!
Code:
Sub Open_Word_Document()
Dim objWord As Object
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Input Sheet")
Set objWord = CreateObject("Word.Application")
objWord.Documents.Open "/Users/user/Desktop/Sales Data/Agreement.docx"
objWord.Visible = True
With objWord.ActiveDocument
.Bookmarks("LiftPrice").Range.Text = ws.Range("C28").Value
.Bookmarks("HSPrice").Range.Text = ws.Range("C30").Value
.Bookmarks("ShedPrice").Range.Text = ws.Range("F30").Value
.Bookmarks("BerthPrice").Range.Text = ws.Range("I30").Value
.Bookmarks("MovePrice").Range.Text = ws.Range("C28").Value
.Bookmarks("Wash").Range.Text = ws.Range("D36").Value
.Bookmarks("LiftDate").Range.Text = ws.Range("C26").Value
.Bookmarks("RTWDate").Range.Text = ws.Range("F26").Value
.Bookmarks("StorageLocation").Range.Text = ws.Range("I26").Value
.Bookmarks("CompanyName").Range.Text = ws.Range("C14").Value
.Bookmarks("Address").Range.Text = ws.Range("F14").Value
.Bookmarks("Number").Range.Text = ws.Range("F12").Value
.Bookmarks("Customer").Range.Text = ws.Range("C12").Value
.Bookmarks("Email").Range.Text = ws.Range("I12").Value
.Bookmarks("Rego").Range.Text = ws.Range("I20").Value
.Bookmarks("VessName").Range.Text = ws.Range("C18").Value
.Bookmarks("VessType").Range.Text = ws.Range("F18").Value
.Bookmarks("BuildYear").Range.Text = ws.Range("I18").Value
.Bookmarks("LOA").Range.Text = ws.Range("C20").Value
.Bookmarks("Beam").Range.Text = ws.Range("F20").Value
.Bookmarks("Tonnage").Range.Text = ws.Range("C22").Value
.Bookmarks("Draft").Range.Text = ws.Range("F22").Value
End With
Set objWord = Nothing
End Sub
Last edited by a moderator: