Option Explicit
#If VBA7 And Win64 Then
Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, lParam As Any) As Long
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare PtrSafe Function ShellExecute Lib "shell32" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#Else
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#End If
Const WM_CLOSE = &H10
Sub ImprimerFichier()
Dim NomFichier As String
NomFichier = [c2] & [b5]
Dim hwnd As Long
ShellExecute FindWindow("XLMAIN", Application.Caption), "print", NomFichier, "", "", 1
Application.Wait (Now + TimeValue("00:00:05")) '==> Attente avant de fermer acrobat sinon acrobat ne se ferme pas
'****************
'Code Pour fermer acrobat
'https://www.mrexcel.com/board/threads/vba-code-to-close-adobe-reader.1020273/
Dim strClassName As String
strClassName = "AcrobatSDIWindow"
hwnd = FindWindow(strClassName, vbNullString)
If hwnd Then
SendMessage hwnd, WM_CLOSE, 0, ByVal 0&
Else
MsgBox "Adobe est toujours ouvert !"
End If
'****************
End Sub