Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automating Excel (XL2002)

I have created a workbook that includes data on one sheet
and a chart based on the data on another. The data is
linked from an Access .mdb. The chart is, in turn,
linked to a Word document. This document contains
several of these linked charts, in a chain from Access to
Excel to Word.

I used Word to automate Excel to requery the database and
therefore update the data on the worksheet, which in turn
updates the chart as it presents in Word. The problem is
that when this procedure is first run (I placed it in the
Document_Open() procedure), it somehow locks the Excel
file so that I have no subsequent access to the file
directly. Interestingly, the procedure still works fine
and continues to update the worksheet. I have tried
restarting Excel and even rebooting, but the worksheet
remains inaccessible. I can't even delete it. Anyone
have any ideas?

Here is the code from Word:

Private Sub Document_Open()

Dim wbk As Object
Set wbk = GetObject("c:\filename.xls")
With wbk
.Sheets("Data_Totals").Range("A2").QueryTable.Refr esh
.Sheets("Totals").Select
.Close (True)
End With
Set wbk = Nothing
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Automating Excel (XL2002)

Randy

Try adding False for the Background argument to Refresh, as in:

.Sheets("Data_Totals").Range("A2").QueryTable.Refr esh False

and see if that helps.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Randy" wrote in message
...
I have created a workbook that includes data on one sheet
and a chart based on the data on another. The data is
linked from an Access .mdb. The chart is, in turn,
linked to a Word document. This document contains
several of these linked charts, in a chain from Access to
Excel to Word.

I used Word to automate Excel to requery the database and
therefore update the data on the worksheet, which in turn
updates the chart as it presents in Word. The problem is
that when this procedure is first run (I placed it in the
Document_Open() procedure), it somehow locks the Excel
file so that I have no subsequent access to the file
directly. Interestingly, the procedure still works fine
and continues to update the worksheet. I have tried
restarting Excel and even rebooting, but the worksheet
remains inaccessible. I can't even delete it. Anyone
have any ideas?

Here is the code from Word:

Private Sub Document_Open()

Dim wbk As Object
Set wbk = GetObject("c:\filename.xls")
With wbk
.Sheets("Data_Totals").Range("A2").QueryTable.Refr esh
.Sheets("Totals").Select
.Close (True)
End With
Set wbk = Nothing
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
XL2002 SUM with a twist... Trevor Williams Excel Worksheet Functions 4 December 9th 09 10:28 AM
XL2002 - VLOOKUP with variable Sheet Name Trevor Williams Excel Worksheet Functions 3 July 29th 08 05:33 PM
Semi-hang in XL2002 Charlie Excel Discussion (Misc queries) 0 May 6th 06 04:53 PM
Using min and max function XL2002 Extremely Aggravated Excel Worksheet Functions 1 September 23rd 05 06:29 PM
Can not open .wb1 file with XL2000 and XL2002 Gaurav Excel Discussion (Misc queries) 1 March 8th 05 12:21 PM


All times are GMT +1. The time now is 02:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"