我有一个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
答案 0 :(得分:2)
Select Case InfoBoxWebSearches.Popup("Updated, saving & closing...", AckTime)
应该是你唯一的错误。你刚刚没有设置等待时间。