Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to execute on WEB Query Refresh
I have a macro I want to run after my WEB Query Refresh takes place. Any
assistance would greatly be appreciated. Regards, Donnie |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to execute on WEB Query Refresh
Hi,
To execute some codes after Query refresh or before Query refresh; 1. add a class module to your VBA project. (assumed name is class1) 2. copy following line into your class module. Public WithEvents qtQueryTable As QueryTable Sub InitQueryEvent(QT As Object) Set qtQueryTable = QT End Sub 3. if you click Object Combobox to drop down, you'll see qtQueryTable on the list. select it. there will be two events available for Query Table. "AfterRefresh and BeforeRefresh". Write your code there. 4. before using these events, you need to set up your query table's AfterRefresh and BeforeRefresh events using following code. (It could be in worksheet's code or workbook's code) Dim clsQueryTable As New Class1 Sub RunInitQTEvent(Optional FakeArg As Integer) clsQueryTable.InitQueryEvent QT:=Sheet1.QueryTables(1) 'assumed your query table in sheet1 End Sub Private Sub Worksheet_Activate() RunInitQTEvent End Sub '///// or ///// Dim clsQueryTable As New Class1 Sub RunInitQTEvent(Optional FakeArg As Integer) clsQueryTable.InitQueryEvent QT:=Sheet1.QueryTables(1) 'assumed your query table in sheet1 End Sub Private Sub Workbook_Open() RunInitQTEvent End Sub Good luck Kind regards. Haldun Alay "Donnie Stone" , iletide şunu yazdı ... I have a macro I want to run after my WEB Query Refresh takes place. Any assistance would greatly be appreciated. Regards, Donnie |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
external data automatic refresh through macro/query | Excel Discussion (Misc queries) | |||
How can I 'Enable Automatic Refresh' for Query Refresh by default | Setting up and Configuration of Excel | |||
Query Refresh-Enable Automatic Refresh Dialogue Box | Excel Discussion (Misc queries) | |||
Web Query Refresh - Automatically Run Macro | Excel Programming | |||
Excel does not close from VB!! (when i refresh Refresh query with BackgroundQuery:=False) | Excel Programming |