Article ID: 182735
Article Last Modified on 11/23/2006
Program Files\Microsoft Office\Office
Public WithEvents qt As QueryTable
Private Sub qt_BeforeRefresh(Cancel As Boolean)
' Declare variables.
Dim a As Integer
Dim My_Prompt As String
' Initialize prompt text for message box.
My_Prompt = "Data will be refreshed."
' Get YES or NO result from the message box
a = MsgBox("Do you want to refresh the data now?", vbYesNoCancel)
' Check to see wheather YES or NO was selected.
If a = vbNo Then
' Change prompt text for message box.
My_Prompt = "Data will not be refreshed."
' Cancels the Query Refresh.
Cancel = True
End If
' Displays message box before refresh (or non-refresh) occurs.
MsgBox My_Prompt
End Sub
NOTE: To use the AfterRefresh event you can replace the macro name
"qt_BeforeRefresh(Cancel As Boolean)" with qt_AfterRefresh(ByVal
Success As Boolean) in the above example. Also, you should change the
message box text to an appropriate post Data Refresh message.
Dim X As New Class1
Sub Initialize_It()
Set X.qt = Thisworkbook.Sheets(1).QueryTables(1)
End Sub
120802 Office: How to Add/Remove a Single Office Program or Component
Additional query words: XL97 Event Query
Keywords: kbhowto KB182735