LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
JVLin
 
Posts: n/a
Default save & close after web query refresh

Hi,

I am trying to automatically save & close a series of workbooks after
refreshing all the web queries they contain.

I have tried to follow the Help instructions on setting up an AfterRefresh
event, but I modified the initiation sub so it refers to the last query table
on the sheet:

Dim clsQueryTable As New ClsModQT

Sub RunInitQTEvent()
Dim clsQueryTable As New ClsModQT
Dim iQ As Integer
iQ = ThisWorkbook.Sheets("Input").QueryTables.Count
clsQueryTable.InitQueryEvent QT:=ThisWorkbook.Sheets("Input").QueryTables(iQ)
End Sub

I was hoping to use this sub in the class module, but it doesn't seem to run:

Sub qtQueryTable_AfterRefresh(ByVal Success As Boolean)
If Success Then
' Query completed successfully
ThisWorkbook.Save
ThisWorkbook.Saved = True
ThisWorkbook.Close
Else
' Query failed or was cancelled
stID = ThisWorkbook.Sheets("Data").Range("ID").Value
MsgBox stID & " did not refresh properly."
ThisWorkbook.Saved = True
ThisWorkbook.Close
End If
End Sub

Do I need to call it explicitly? And if so, how do I do that from another
workbook?

Regards,

JvL
 
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
Disable Query Refresh warning dialog box in Excel 2003 Jeff Koons Excel Discussion (Misc queries) 2 December 1st 05 04:08 PM
HELP! Lose Database Query upon Refresh Magela Excel Worksheet Functions 0 April 1st 05 09:11 PM
Save Changes Prompt at close Johnewally Excel Discussion (Misc queries) 2 March 17th 05 09:15 PM
automatic query refresh sid Excel Discussion (Misc queries) 1 March 14th 05 09:02 PM
Prompting to allow External Query Data Refresh Tim Baker Excel Discussion (Misc queries) 3 March 8th 05 11:29 AM


All times are GMT +1. The time now is 02:40 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"