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

I have a workbook "B.xls" that when opened, I need a linked query
refreshed. This is now manually done by choosing the "Enable automatic
refresh" button on the Query refresh dialogue box that pops up when
the file is opened manually.

I have added code in workbook A.xls behind a button that opens
workbook B.xls. Works fine EXCEPT that the query DOES NOT get
refreshed and no dialogue box pops up.

Can anyone suggest code to add to my workbook.open that will run the
query refresh?

Dim wkbk As Workbook

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 ")
End If

Thanks
Dennis

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Workbook Open bypasses Query Refresh

hi
never done it that way before but try adding this after open......

RANGE("A1").QueryTable.Refresh BackgroundQuery:=False

regards
FSt1

"ssGuru" wrote:

I have a workbook "B.xls" that when opened, I need a linked query
refreshed. This is now manually done by choosing the "Enable automatic
refresh" button on the Query refresh dialogue box that pops up when
the file is opened manually.

I have added code in workbook A.xls behind a button that opens
workbook B.xls. Works fine EXCEPT that the query DOES NOT get
refreshed and no dialogue box pops up.

Can anyone suggest code to add to my workbook.open that will run the
query refresh?

Dim wkbk As Workbook

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 ")
End If

Thanks
Dennis


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Workbook Open bypasses Query Refresh

hi
afterthought
make sure your range in within the query table. otherwise it wont refresh.

regards
FSt1

"FSt1" wrote:

hi
never done it that way before but try adding this after open......

RANGE("A1").QueryTable.Refresh BackgroundQuery:=False

regards
FSt1

"ssGuru" wrote:

I have a workbook "B.xls" that when opened, I need a linked query
refreshed. This is now manually done by choosing the "Enable automatic
refresh" button on the Query refresh dialogue box that pops up when
the file is opened manually.

I have added code in workbook A.xls behind a button that opens
workbook B.xls. Works fine EXCEPT that the query DOES NOT get
refreshed and no dialogue box pops up.

Can anyone suggest code to add to my workbook.open that will run the
query refresh?

Dim wkbk As Workbook

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 ")
End If

Thanks
Dennis


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Workbook Open bypasses Query Refresh

Thanks FSt1,
I gave that a try but apparently I don't know how to implement
correctly.
I get an error though the Range appears to be valid.
I have named a cell "LicActiveQuery" that is in the header of the area
on a sheet that the Db query updates.
I also tried a specific Range cell $G$1 but it wasn't happy with that
either.

My query to an external .xls file works just fine and is used to
update and repopulate a list in a table in the a local worksheet in
B.xls workbook.
This is the query that I referred to in my opening post that works
fine IF manually refreshed.

UPDATED Code:
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

Any other thoughts appreciated.
Dennis


On Feb 12, 4:21*am, FSt1 wrote:
hi
afterthought
make sure your range in within the query table. otherwise it wont refresh.

regards
FSt1



"FSt1" wrote:
hi
never done it that way before but try adding this after open......


RANGE("A1").QueryTable.Refresh BackgroundQuery:=False


regards
FSt1


"ssGuru" wrote:


I have a workbook "B.xls" that when opened, I need a linked query
refreshed. This is now manually done by choosing the "Enable automatic
refresh" button on the Query refresh dialogue box that pops up when
the file is opened manually.


I have added code in workbook A.xls behind a button that opens
workbook B.xls. *Works fine EXCEPT that the query DOES NOT get
refreshed and no dialogue box pops up.


Can anyone suggest code to add to my workbook.open that will run the
query refresh?


Dim wkbk As Workbook


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 ")
* * End If


Thanks
Dennis- Hide quoted text -


- Show quoted text -


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
Unable to open after auto refresh(Query) Irmann Excel Discussion (Misc queries) 0 January 8th 08 06:33 AM
Refresh Ext Date Range Query with workbook closed? (Exc2003) Finny388 Excel Programming 1 November 24th 07 02:20 AM
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
Supress Query Refresh dialog on opening workbook Paul Tugwell Excel Programming 1 August 8th 05 11:27 PM


All times are GMT +1. The time now is 06:40 AM.

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"