1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Option Explicit
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassname As String, ByVal lpWindowName As String) As Long
Private Const WM_CLOSE = &H10
Private Sub btnclosepdf_Click()
Dim Hwnd As Long
'~~> Find the window of the pdf file
Hwnd = FindWindow(vbNullString, "NomDuFichier.pdf - Architect 7")
If Hwnd Then
'~~> Close the file
PostMessage Hwnd, WM_CLOSE, 0, ByVal 0&
Else
MsgBox "Pdf File not found"
End If
End Sub |
Partager