Hello Rerock,
Here is the 64 bit version of the macro.
' 64 Fit Windows API Calls.
Private Declare PtrSafe Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As LongPtr, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare PtrSafe Function GetNextWindow Lib "user32.dll" Alias "GetWindow" (ByVal hwnd As LongPtr, ByVal wFlag As Long) As LongPtr
Private Declare PtrSafe Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
Sub ClosePDF(ByVal FileName As String)
Dim Found As Boolean
Dim hwnd As LongPtr
Dim RefCell As Range
Dim ret As LongPtr
Dim Title As String
Dim WndCls As String
Const GW_HWNDNEXT As Long = 2
Const WM_CLOSE As Long = 16
If FileName = "" Then Exit Sub
hwnd = FindWindow(vbNullString, vbNullString)
Do Until hwnd = 0
WndCls = String(512, Chr(0))
ret = GetClassName(hwnd, WndCls, 512)
If Left(WndCls, ret) = "AcrobatSDIWindow" Then
Title = String(512, Chr(0))
ret = GetWindowText(hwnd, Title, Len(Title))
If InStr(1, Title, FileName, vbTextCompare) Then
ret = SendMessage(hwnd, WM_CLOSE, 0, ByVal 0)
Found = True
Exit Do
End If
End If
hwnd = GetWindow(hwnd, GW_HWNDNEXT)
Loop
If Not Found Then MsgBox "The Following PDF Document Was Not Found :" & vbCrLf & vbCrLf & FileName
End Sub
Bookmarks