Word Application not opening properly

MWbris

New Member
Joined
Jan 31, 2017
Messages
8
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;
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:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,223,794
Messages
6,174,641
Members
452,575
Latest member
Fstick546

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top