Suite à un post ici où je cherchais à récupérer le contenu d'un fichier pdf
(ce qui marche très bien), je n'arrives pas à fermer l'application Acrobat
Reader à la fin de mon traitement...
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
Sub Extraire_Texte_de_Pdf()
URL = "C:\mes documents\Gazel_no22.pdf" 'Adapter à votre fichier
'Ouvrir le fichier pdf avec le programme approprié
ShellExecute 0&, vbNullString, URL, vbNullString, _
vbNullString, vbNormalFocus
Private Declare Function GetWindowThreadProcessId& Lib "user32" _ (ByVal Hwnd&, lpdwProcessId&)
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" _ (ByVal Hwnd&, ByVal wMsg&, ByVal wParam&, lParam As Any)
Private Declare Function GetParent& Lib "user32" _ (ByVal Hwnd&)
Private Declare Function FindExecutable& Lib "shell32" Alias "FindExecutableA" _ (ByVal lpFile$, ByVal lpDirectory$, ByVal lpResult$)
Private Apphwnd&
Sub Ferme_Pdf() Const WM_SYSCOMMAND& = &H112, SC_CLOSE& = &HF060 SendMessage Apphwnd, WM_SYSCOMMAND, SC_CLOSE, 0& End Sub
Sub Extraire_Texte_de_Pdf() Dim URL$ URL = "C:mes documentsGazel_no22.pdf" 'Adapter à votre fichier 'Ouvrir le fichier pdf avec le programme approprié EnumWindows AddressOf EnumWindowsProc, Shell(TrouveEXE(URL) & " """ & URL & """", vbNormalFocus) End Sub
Private Function TrouveEXE$(LeFile$) Dim Exe$ Const MAX_PATH& = 260& Exe = Space$(MAX_PATH) FindExecutable LeFile, "", Exe TrouveEXE = Left$(Exe, InStr(Exe, vbNullChar) - 1&) End Function
Private Function EnumWindowsProc&(ByVal Hwnd&, ByVal lngParam&) Dim test_pid& GetWindowThreadProcessId Hwnd, test_pid If test_pid = lngParam And GetParent(Hwnd) = 0& Then Apphwnd = Hwnd Else EnumWindowsProc = True End Function
Alain CROS
"artis31" a écrit dans le message de news: u0#
Bonjour,
Suite à un post ici où je cherchais à récupérer le contenu d'un fichier pdf (ce qui marche très bien), je n'arrives pas à fermer l'application Acrobat Reader à la fin de mon traitement...
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
Sub Extraire_Texte_de_Pdf()
URL = "C:mes documentsGazel_no22.pdf" 'Adapter à votre fichier 'Ouvrir le fichier pdf avec le programme approprié ShellExecute 0&, vbNullString, URL, vbNullString, _ vbNullString, vbNormalFocus
Private Declare Function GetWindowThreadProcessId& Lib "user32" _
(ByVal Hwnd&, lpdwProcessId&)
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" _
(ByVal Hwnd&, ByVal wMsg&, ByVal wParam&, lParam As Any)
Private Declare Function GetParent& Lib "user32" _
(ByVal Hwnd&)
Private Declare Function FindExecutable& Lib "shell32" Alias "FindExecutableA" _
(ByVal lpFile$, ByVal lpDirectory$, ByVal lpResult$)
Private Apphwnd&
Sub Ferme_Pdf()
Const WM_SYSCOMMAND& = &H112, SC_CLOSE& = &HF060
SendMessage Apphwnd, WM_SYSCOMMAND, SC_CLOSE, 0&
End Sub
Sub Extraire_Texte_de_Pdf()
Dim URL$
URL = "C:mes documentsGazel_no22.pdf" 'Adapter à votre fichier
'Ouvrir le fichier pdf avec le programme approprié
EnumWindows AddressOf EnumWindowsProc, Shell(TrouveEXE(URL) & " """ & URL & """", vbNormalFocus)
End Sub
Private Function TrouveEXE$(LeFile$)
Dim Exe$
Const MAX_PATH& = 260&
Exe = Space$(MAX_PATH)
FindExecutable LeFile, "", Exe
TrouveEXE = Left$(Exe, InStr(Exe, vbNullChar) - 1&)
End Function
Private Function EnumWindowsProc&(ByVal Hwnd&, ByVal lngParam&)
Dim test_pid&
GetWindowThreadProcessId Hwnd, test_pid
If test_pid = lngParam And GetParent(Hwnd) = 0& Then Apphwnd = Hwnd Else EnumWindowsProc = True
End Function
Alain CROS
"artis31" <artis31@free.fr> a écrit dans le message de news: u0#O67aUEHA.2724@TK2MSFTNGP11.phx.gbl...
Bonjour,
Suite à un post ici où je cherchais à récupérer le contenu d'un fichier pdf
(ce qui marche très bien), je n'arrives pas à fermer l'application Acrobat
Reader à la fin de mon traitement...
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
Sub Extraire_Texte_de_Pdf()
URL = "C:mes documentsGazel_no22.pdf" 'Adapter à votre fichier
'Ouvrir le fichier pdf avec le programme approprié
ShellExecute 0&, vbNullString, URL, vbNullString, _
vbNullString, vbNormalFocus
Private Declare Function GetWindowThreadProcessId& Lib "user32" _ (ByVal Hwnd&, lpdwProcessId&)
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" _ (ByVal Hwnd&, ByVal wMsg&, ByVal wParam&, lParam As Any)
Private Declare Function GetParent& Lib "user32" _ (ByVal Hwnd&)
Private Declare Function FindExecutable& Lib "shell32" Alias "FindExecutableA" _ (ByVal lpFile$, ByVal lpDirectory$, ByVal lpResult$)
Private Apphwnd&
Sub Ferme_Pdf() Const WM_SYSCOMMAND& = &H112, SC_CLOSE& = &HF060 SendMessage Apphwnd, WM_SYSCOMMAND, SC_CLOSE, 0& End Sub
Sub Extraire_Texte_de_Pdf() Dim URL$ URL = "C:mes documentsGazel_no22.pdf" 'Adapter à votre fichier 'Ouvrir le fichier pdf avec le programme approprié EnumWindows AddressOf EnumWindowsProc, Shell(TrouveEXE(URL) & " """ & URL & """", vbNormalFocus) End Sub
Private Function TrouveEXE$(LeFile$) Dim Exe$ Const MAX_PATH& = 260& Exe = Space$(MAX_PATH) FindExecutable LeFile, "", Exe TrouveEXE = Left$(Exe, InStr(Exe, vbNullChar) - 1&) End Function
Private Function EnumWindowsProc&(ByVal Hwnd&, ByVal lngParam&) Dim test_pid& GetWindowThreadProcessId Hwnd, test_pid If test_pid = lngParam And GetParent(Hwnd) = 0& Then Apphwnd = Hwnd Else EnumWindowsProc = True End Function
Alain CROS
"artis31" a écrit dans le message de news: u0#
Bonjour,
Suite à un post ici où je cherchais à récupérer le contenu d'un fichier pdf (ce qui marche très bien), je n'arrives pas à fermer l'application Acrobat Reader à la fin de mon traitement...
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
Sub Extraire_Texte_de_Pdf()
URL = "C:mes documentsGazel_no22.pdf" 'Adapter à votre fichier 'Ouvrir le fichier pdf avec le programme approprié ShellExecute 0&, vbNullString, URL, vbNullString, _ vbNullString, vbNormalFocus