尚方宝剑之说
sendkeys 有2个参数的,第2个参数为TRUE,则 Microsoft Excel 等待击键处理完后再将控制返回到宏那么写成Application.QuitApplication.SendKeys "{tab}",TRUEApplication.SendKeys "{enter}",TRUE这样应该行了,MSDN说,向对话框发送按键时,需要先调用SENDKEYS...,我在做试验时,上写的2种方法都可以正常退出..没看出区别,可能是EXCEL版本不一样。
肥皂起泡泡
用API吧Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Sub CommandButton1_Click()Dim i As Longkeybd_event &H12, 0, 0, 0For i = 1 To 5keybd_event &H9, 0, 0, 0Sleep 1000keybd_event &H9, 0, &H2, 0Nextkeybd_event &H12, 0, &H2, 0End Sub