Open a PDF in Acrobat Reader using VB?
Solved
YAYA
-
loulou -
loulou -
Bonjour, je suis là pour traduire votre texte. Voici la traduction :
Hello, I would like to get a little help...
So, I would like to launch Acrobat Reader in VB to automatically open a PDF document. I tried using the Shell function, but it only works to execute .exe files.
So a big thank you to anyone who can help me.
If I wasn't clear enough, just let me know!
So, I would like to launch Acrobat Reader in VB to automatically open a PDF document. I tried using the Shell function, but it only works to execute .exe files.
So a big thank you to anyone who can help me.
If I wasn't clear enough, just let me know!
6 answers
Hello,
it might be a bit late but it could help others,
in the Shell I didn't put a "+" just a space maybe that's where your mistake comes from...
it might be a bit late but it could help others,
in the Shell I didn't put a "+" just a space maybe that's where your mistake comes from...
slt colin
please I'm compiling the following code but only the reader.exe opens; however, my PDF document does not open. Can you tell me where the problem is in my code?
the code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Integer, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer
Private Sub Command1_Click()
Dim ret As Long
ret = Shell("C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe + C:\best practise IT VF rev1.pdf")
End Sub
thank you in advance
please I'm compiling the following code but only the reader.exe opens; however, my PDF document does not open. Can you tell me where the problem is in my code?
the code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Integer, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer
Private Sub Command1_Click()
Dim ret As Long
ret = Shell("C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe + C:\best practise IT VF rev1.pdf")
End Sub
thank you in advance
You can use ShellExecute:
The declaration, in a Module:
The usage:
@+
The declaration, in a Module:
Public 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
The usage:
ShellExecute 0&, vbNullString, &ActiveWorkbook.Path & "\test.pdf", MyParameter, vbNullString, vbNormalFocus
@+
Bonjour,
cette fonction marche à merveille sur mon appli mais comment prendre en compte le fait que les utilisateurs peuvent avoir des versions d'Adobe Reader différentes et donc des chemins d'accès eux aussi différents dans la fonction Shell.
En gros, quelle fonction logique me permettra d'essayer le premier chemin et si cela ne fonctionne pas, le second ?
Voici mon code pour cette fonction :
Private Sub Groupe49_QuandClic()
'Bouton
Shell "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.EXE " & ActiveWorkbook.Path & "\test.pdf", vbNormalFocus
End Sub
Et je voudrais qu'il donne aussi en seconde possibilité d'activer la fonction shell suivante:
Shell "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.EXE " & ActiveWorkbook.Path & "\test.pdf", vbNormalFocus
Merci de votre aide !
cette fonction marche à merveille sur mon appli mais comment prendre en compte le fait que les utilisateurs peuvent avoir des versions d'Adobe Reader différentes et donc des chemins d'accès eux aussi différents dans la fonction Shell.
En gros, quelle fonction logique me permettra d'essayer le premier chemin et si cela ne fonctionne pas, le second ?
Voici mon code pour cette fonction :
Private Sub Groupe49_QuandClic()
'Bouton
Shell "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.EXE " & ActiveWorkbook.Path & "\test.pdf", vbNormalFocus
End Sub
Et je voudrais qu'il donne aussi en seconde possibilité d'activer la fonction shell suivante:
Shell "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.EXE " & ActiveWorkbook.Path & "\test.pdf", vbNormalFocus
Merci de votre aide !
Pour ouvrir un fichier PDF, vous pouvez utiliser un lecteur PDF comme Adobe Acrobat Reader, qui est gratuit et facile à utiliser. Vous pouvez également essayer d'autres options comme Foxit Reader ou même ouvrir le fichier dans un navigateur web comme Google Chrome ou Microsoft Edge. Si vous avez besoin d'aide pour installer un de ces logiciels, n'hésitez pas à demander.