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_HIDE = &H10000 'Hide
Const AW_SLIDE = &H40000 'Slide animation.
Const AW_VER_NEGATIVE = &H8 'Animates Word from bottom to top.
Private Sub Document_Close()
Dim lngFrmWindow As Long
'Retrieve a handle to Word
'OpusApp is the Class name for Word 2000/2002
'ActiveDocument.Name & " - " & Application.Name
'retrieves Word's window title text, this is what we need
lngFrmWindow = FindWindow("OpusApp", ActiveDocument.Name & " - " & Application.Name)
If lngFrmWindow <> 0 Then 'lngFrmWindow returns a zero if there's an error
'Make Word roll upwards and exit
'750 is in milliseconds the time length of the animation
AnimateWindow lngFrmWindow, 750, AW_SLIDE Or AW_VER_NEGATIVE Or AW_HIDE
Else 'An error has occured with the AnimateWindow function
Call MsgBox("There was an error when trying to animate the Word window." _
& vbCrLf & "" _
, vbCritical, Application.Name)
End If
'Quit Word
Application.Quit
End Sub
|