Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ouvrir un pdf en VBA

758 views
Skip to first unread message

ThierryP

unread,
Mar 6, 2012, 10:05:17 AM3/6/12
to
Bonjour à tou(te)s,

Je cherche à ouvrir un fichier pdf via VBA, et ceci le fait :

Shell "C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe"
& Fichier, vbMaximizedFocus

Mais, il y a toujours un mais......, y a-t-il moyen de se passer de
définir l'exécutable, un peu comme un lien hypertexte ouvre un fichier
avec l'exécutable défini par défaut ?

Merci d'avance de vos réponses éclairées !!!

ThierryP

MichD

unread,
Mar 6, 2012, 10:25:19 AM3/6/12
to
Bonjour,

Il y a cette façon de faire :


'Dans le haut du module, déclaration de l'API
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 Ouvrir_Un_Fichier()
Dim Fichier As String
Fichier = "C:\Chemin complet\Mon_Fichier.pdf"
If Dir(Fichier) <> "" Then
ShellExecute 0, "open", Fichier, "", "", 0
End If
End Sub
'---------------------------------


MichD
------------------------------------------
"ThierryP" a écrit dans le message de groupe de discussion :
e5746be3-061c-4f7a...@l14g2000vbe.googlegroups.com...

ThierryP

unread,
Mar 6, 2012, 10:46:49 AM3/6/12
to
Bonjour Denis,

Super, comme toujours :-)))))))

Un grand merci !!!

ThierryP

On 6 mar, 16:25, "MichD" <michde...@hotmail.com> wrote:
> Bonjour,
>
> Il y a cette façon de faire :
>
> 'Dans le haut du module, déclaration de l'API
> 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 Ouvrir_Un_Fichier()
> Dim Fichier As String
> Fichier = "C:\Chemin complet\Mon_Fichier.pdf"
> If Dir(Fichier) <> "" Then
>     ShellExecute 0, "open", Fichier, "", "", 0
> End If
> End Sub
> '---------------------------------
>
> MichD
> ------------------------------------------
> "ThierryP"  a écrit dans le message de groupe de discussion :
> e5746be3-061c-4f7a-abae-69c88733a...@l14g2000vbe.googlegroups.com...
0 new messages