我希望刷新查询后出现vbOK消息框。
我已经在这里完成了一些答案,并试图将其拼凑在一起,但是我无法弄清自己在做错什么。
这在ThisWorkbook中:
Dim qtevent As qtclass
-------------------------------------------------
Private Sub Workbook_Open()
Set qtevent = New qtclass
Set qtevent.HookedTable =
ThisWorkbook.Worksheets("TagData").ListObjects("barTagData").QueryTable
End Sub
-------------------------------------------------
Sub refreshData()
Refresh_Note.Show vbModeless
Application.ScreenUpdating = True
Application.DisplayAlerts = False
With ThisWorkbook
.Connections("Query - PSTab").OLEDBConnection.BackgroundQuery = True
.Connections("Query - PETab").OLEDBConnection.BackgroundQuery = True
.Connections("Query - barTagData").OLEDBConnection.BackgroundQuery = True
.Connections("Query - PSTab").Refresh
.Connections("Query - PETab").Refresh
.Connections("Query - barTagData").Refresh
End With
DoEvents
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
-------------------------------------------------
这是qtclass模块:
Option Explicit
Public WithEvents qt As QueryTable
-------------------------------------------------
Public Property Set HookedTable(q As Excel.QueryTable)
Set qt = q
End Property
-------------------------------------------------
Private Sub qt_AfterRefresh(ByVal Success As Boolean)
MsgBox "qt_AfterRefresh called successfully."
If Success = True Then
Call hideForm
MsgBox "If called Successfully"
End Sub
-------------------------------------------------
Sub hideForm()
Refresh_Note.Hide
End Sub
-------------------------------------------------
需要任何帮助! :)谢谢。
在刷新查询后,我尝试调用hideForm子项,这也会产生另一个msg框,说明“查询已刷新”。这部分已经准备好了,但是该子级没有被称为AfterRefresh。