Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Refresh Query on open failing

I'm getting a 1004 error when I try to refresh a query as I open a
Workbook using code.

The field named "LicActiveQuery" IS at at the top right of the table
that the query refreshes. Shouldn't I be able to use a named range
rather than a row col number as long as it is within the query result
table?

On Error Resume Next
Set wkbk = Workbooks("B.xls")
On Error GoTo 0
If wkbk Is Nothing Then
Set wkbk = Workbooks.Open(Filename:="C:\Data\ClientName
\B.xls")


'RANGE ERROR Creates an "Run-time error '1004':
' "Method 'Range' of object'_Worksheet' failed
Range("LicActiveQuery").QueryTable.Refresh
BackgroundQuery:=False


End If

Thanks,
Dennis
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Refresh Query on open failing

Try referring to the query table rather than a range:

yoursheet.QueryTables(1).Refresh BackgroundQuery:=False

Cliff Edwards
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
Workbook Open bypasses Query Refresh ssGuru Excel Programming 3 February 12th 08 07:47 PM
Unable to open after auto refresh(Query) Irmann Excel Discussion (Misc queries) 0 January 8th 08 06:33 AM
Data query failing jtrai491 Excel Worksheet Functions 1 November 13th 06 08:10 PM
Refresh business query on open SITO Excel Discussion (Misc queries) 1 August 15th 06 02:57 PM
Auto Open file VBA Refresh MS Query Save Close gcutter[_2_] Excel Programming 2 September 26th 05 03:07 PM


All times are GMT +1. The time now is 08:59 PM.

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

About Us

"It's about Microsoft Excel"