Hi,
I try to use for the first time a vb Excel macro called Private Sub QueryTable_AfterRefresh(Success As Boolean).
The situation: several columns in an Excel-worksheet ("Sheet1" are updated automatically each 10 minutes by a databasequery. I use this method for the first time. This query works fine. Immediately after each query some tasks have to be executed, for which I want to write code in the sub AfterRefresh.
My problem: Despite the "explanations" in vb-help, I do not understand how to make it work. Upto now, in the vb-editor I have created a classmodule, called Klasse1. In this module I have written following lines (which until now do not make any sense to me. LOL):
Public WithEvents qtQueryTable As QueryTable
Private Sub Class_Initialise()
'I don't know if I have to use this and which code
'it should contain.
End Sub
Sub InitQueryEvent(QT As Object)
Set qtQueryTable = QT
End Sub
Private Sub QueryTable-AfterRefresh(Success As Boolean)
If Success Then
Msgbox "Refresh successfully executed"
Else
Msgbox "Refresh failed"
End If
End sub
Can anyone tell me what I have to do to make the sub AfterRefresh work?
Thank you for your help. Greetings,
Rudo (Holland)
I try to use for the first time a vb Excel macro called Private Sub QueryTable_AfterRefresh(Success As Boolean).
The situation: several columns in an Excel-worksheet ("Sheet1" are updated automatically each 10 minutes by a databasequery. I use this method for the first time. This query works fine. Immediately after each query some tasks have to be executed, for which I want to write code in the sub AfterRefresh.
My problem: Despite the "explanations" in vb-help, I do not understand how to make it work. Upto now, in the vb-editor I have created a classmodule, called Klasse1. In this module I have written following lines (which until now do not make any sense to me. LOL):
Public WithEvents qtQueryTable As QueryTable
Private Sub Class_Initialise()
'I don't know if I have to use this and which code
'it should contain.
End Sub
Sub InitQueryEvent(QT As Object)
Set qtQueryTable = QT
End Sub
Private Sub QueryTable-AfterRefresh(Success As Boolean)
If Success Then
Msgbox "Refresh successfully executed"
Else
Msgbox "Refresh failed"
End If
End sub
Can anyone tell me what I have to do to make the sub AfterRefresh work?
Thank you for your help. Greetings,
Rudo (Holland)