1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| ' --- DECLARATION API WINDOWS
Private Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" ( _
ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpszParams As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) _
As Long
'
Public Function ShellExec( _
ByVal strFichier As String, _
Optional ByVal strOperation As String = "Open", _
Optional ByVal strszParams As String = "/A page=pagenum", _
Optional ByVal awsAffichage As VbAppWinStyle = VbAppWinStyle.vbNormalFocus, _
Optional ByVal strParametres As String = "", _
Optional ByVal strDossier As String = "") _
As Boolean
Dim lngRes As Long
lngRes = ShellExecute(Access.hWndAccessApp, strOperation, _
strFichier, strParametres, strDossier, strszParams, awsAffichage)
ShellExec = (lngRes < 0) Or (lngRes > 32)
End Function
Private Sub btn_pdf_Click()
Dim Chemin As String
Dim Fichier As String
'On ne continue que si un fichier a été sélectionné.
If Me.txt_pdf.Value <> "" Then
Fichier = Me.txt_pdf.Value
'Association des chemins absolu et relatif pour obtenir le chemin complet vers le fichier.
Chemin = CurrentProject.Path & "\Réf trémie et porte P4\" & Fichier & ".pdf"
'Affichage de la page concernée
MsgBox ("La trémie est renseignée à la page " & Me.txt_page.Value & " du PDF.")
'Execution du fichier situé à l'emplacement "Chemin" avec son programme par défaut.
ShellExec (Chemin)
Else
MsgBox "Aucun fichier sélectionné"
End If |
Partager