![]() |
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 |
All times are GMT +1. The time now is 07:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com