![](/img/trans.png)
[英]Excel VBA Message Box when there are no blank fields in an autofilter and stop macro
[英]VBA Excel macro message box auto close
我有一個Excel宏,可以在打開文件,打開另一個excel文件,刷新數據,保存然后關閉時運行。
我還有一個中間位(Dim AckTime),它會顯示一條彈出消息,以顯示第二步。
但是,由於我將宏設置為在使用Public Sub Workbook_Open()打開工作簿時運行,因此會彈出消息框,但不會在1秒后自動關閉。
有人可以幫忙嗎?
Public Sub Workbook_Open()
Application.ScreenUpdating = False Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
With Workbooks.Open("\\filename.xlsm")
ActiveWorkbook.RefreshAll 'updates the data
ActiveWorkbook.Sheets("Dashboard").Range("A2").Value = DateTime.Now
' updates this cell with the current time
Dim AckTime As Integer, InfoBoxWebSearches As Object
Set InfoBoxWebSearches = CreateObject("WScript.Shell")
AckTime = 1
Select Case InfoBoxWebSearches.Popup("Updated, saving & closing...", _
Case 1, -1
End Select
.Save
.Saved = True 'when saved..
.Close 0 'close the file
End With
End Sub
Select Case InfoBoxWebSearches.Popup("Updated, saving & closing...", AckTime)
應該是您唯一的錯誤。 您只是沒有設置等待時間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.