Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Disable Query Refresh warning dialog box in Excel 2003 | Excel Discussion (Misc queries) | |||
HELP! Lose Database Query upon Refresh | Excel Worksheet Functions | |||
Save Changes Prompt at close | Excel Discussion (Misc queries) | |||
automatic query refresh | Excel Discussion (Misc queries) | |||
Prompting to allow External Query Data Refresh | Excel Discussion (Misc queries) |