Option Explicit
Private Declare Function AnimateWindow Lib "USER32" (ByVal hWnd As Long, ByVal _
dwTime As Long, ByVal dwFlags As Long) As Boolean
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal _
lpClassName As String, ByVal lpWindowName As String) As Long
Const AW_CENTER = &H10
Const AW_HIDE = &H10000
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim lngFrmWindow As Long
lngFrmWindow = FindWindow("XLMAIN", Application.Name & " - " & ActiveWorkbook.Name)
If lngFrmWindow <> 0 Then
AnimateWindow lngFrmWindow, 750, AW_CENTER Or AW_HIDE
Else
Call MsgBox("There was an error when trying to animate the Excel window." _
& vbCrLf & "" _
, vbCritical, Application.Name)
End If
Application.Quit
End Sub
|