Dim xl As New Excel.Application
Dim WorkbookOpen As Workbook
Set WorkbookOpen = xl.Workbooks.Open("c:\test.xls", , False)
xl.Visible = True
DoEvents
MsgBox "ok"
On Error Resume Next
WorkbookOpen.Close
Set WorkbookOpen = Nothing
Set xl = Nothing
On Error GoTo 0
我想等用户关闭EXCEL后弹出"ok"提示框,怎么做?

解决方案 »

  1.   

    Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Sub Command1_Click()    Debug.Print Now
        
        Call Sleep(1000)  '暫停1s
        
        Debug.Print Now
    End Sub
      

  2.   

    谢谢,不过不是这样的,我是想暂时把控制权交给用户,当用户关闭excel后,在进行下面的程序。
      

  3.   

    Dim xl As New Excel.Application
    Dim WorkbookOpen As Workbook
    Set WorkbookOpen = xl.Workbooks.Open("c:\test.xls", , False)
    xl.Visible = TrueDo While xl.Visible
    DoEvents
    LoopMsgBox "ok"
    On Error Resume Next
    WorkbookOpen.Close
    Set WorkbookOpen = Nothing
    Set xl = Nothing
    On Error GoTo 0