• Automation w/ Excel (Word 2002)

    Author
    Topic
    #395709

    How about closing the workbook before you set wbk to Nothing.

    StuartR

    I just reread your post and noticed the .Close(True), sorry I had missed it first time round. Time to think again.

    Viewing 0 reply threads
    Author
    Replies
    • #736571

      I have created a Word document with a linked Excel chart. There is code that updates the data for the chart automatically. After I run this code within Word, the excel file that contained the data and the chart is no longer accessible. I cannot open it for further editing. Interestingly, though, running the apparently offending macro in Word still accesses the Excel chart and updates the data like it is suppose to. How weird is that?? Is there something else I should have done in order to release that file?

      Here is the code I ended up with:
      [indent]


      Private Sub Document_Open()

      Dim wbk As Object

      Set wbk = GetObject(“C:test1.xls”)
      With wbk
      .Sheets(“sheet1”).Range(“A2”).QueryTable.Refresh
      .Sheets(“chart1”).Select
      .Close (True)
      End With

      Set wbk = Nothing
      End Sub


      [/indent]

    Viewing 0 reply threads
    Reply To: Automation w/ Excel (Word 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: