View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ssGuru ssGuru is offline
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