Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

acces a document pdf a partir d'excel

4 réponses
Avatar
yan
Bonjour à tous
Est-il possible a l'aide d'une procédure vba d'ouvrir un fichier acrobat
(pdf).
J'ai une procédure qui le fait pour des fichiers "word" mais je n'arrive pas
a le transposer pour acrobat
Si cela est possible quel serait le code?
Merci a vous
Yan

4 réponses

Avatar
Daniel.j
Bonjour
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
Private Const SW_SHOWNORMAL As Long = 1
Sub test()
ShellExecute hwnd, "open", "C:tonfichier.pdf", vbNullString,
vbNullString, SW_SHOWNORMAL
End Sub

--
Daniel
FAQ MPFE
http://dj.joss.free.fr/faq.htm

VBAXL
http://dj.joss.free.fr/


"yan" a écrit dans le message de news:
47db67be$0$844$
Bonjour à tous
Est-il possible a l'aide d'une procédure vba d'ouvrir un fichier acrobat
(pdf).
J'ai une procédure qui le fait pour des fichiers "word" mais je n'arrive
pas a le transposer pour acrobat
Si cela est possible quel serait le code?
Merci a vous
Yan




Avatar
yan
Re bonjour
Je viens d'essayer c'est parfait je te remercie. Mes connaissances actuelles
ne me permettent pas de comprendre ce code mais l'essentiel c'est qu'il
fonctionne
Est ce que d'une façon plus générale ce code permet d'ouvrir n'importe quel
type de fichier ( pdf,doc,dwg,....)
encore merci
bon week-end
yan


"Daniel.j" a écrit dans le message de news:

Bonjour
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
Private Const SW_SHOWNORMAL As Long = 1
Sub test()
ShellExecute hwnd, "open", "C:tonfichier.pdf", vbNullString,
vbNullString, SW_SHOWNORMAL
End Sub

--
Daniel
FAQ MPFE
http://dj.joss.free.fr/faq.htm

VBAXL
http://dj.joss.free.fr/


"yan" a écrit dans le message de news:
47db67be$0$844$
Bonjour à tous
Est-il possible a l'aide d'une procédure vba d'ouvrir un fichier acrobat
(pdf).
J'ai une procédure qui le fait pour des fichiers "word" mais je n'arrive
pas a le transposer pour acrobat
Si cela est possible quel serait le code?
Merci a vous
Yan








Avatar
Daniel.j
oui en effet avec cette variante (pour plus de facilité)
================= Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal fsShowCmd As Long) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Const SW_SHOWNORMAL = 1

Function StartDoc(DocName As String) As Long
Dim Scr_hDC As Long
Scr_hDC = GetDesktopWindow()
StartDoc = ShellExecute(Scr_hDC, "Open", DocName, _
"", "C:", SW_SHOWNORMAL)
End Function

Sub Test()
Dim r As Long
' r = StartDoc("C:ajeterformation.doc")
' r = StartDoc("C:ajetervbnet.pdf")
StartDoc ("http://dj.joss.free.fr")
'StartDoc ("C:WINDOWSsystem32ssmarque.scr")
End Sub


--
Daniel
FAQ MPFE
http://dj.joss.free.fr/faq.htm

VBAXL
http://dj.joss.free.fr/

"yan" a écrit dans le message de news:
47db9531$0$852$
Re bonjour
Je viens d'essayer c'est parfait je te remercie. Mes connaissances
actuelles ne me permettent pas de comprendre ce code mais l'essentiel
c'est qu'il fonctionne
Est ce que d'une façon plus générale ce code permet d'ouvrir n'importe
quel type de fichier ( pdf,doc,dwg,....)
encore merci
bon week-end
yan


"Daniel.j" a écrit dans le message de news:

Bonjour
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
Private Const SW_SHOWNORMAL As Long = 1
Sub test()
ShellExecute hwnd, "open", "C:tonfichier.pdf", vbNullString,
vbNullString, SW_SHOWNORMAL
End Sub

--
Daniel
FAQ MPFE
http://dj.joss.free.fr/faq.htm

VBAXL
http://dj.joss.free.fr/


"yan" a écrit dans le message de news:
47db67be$0$844$
Bonjour à tous
Est-il possible a l'aide d'une procédure vba d'ouvrir un fichier
acrobat (pdf).
J'ai une procédure qui le fait pour des fichiers "word" mais je n'arrive
pas a le transposer pour acrobat
Si cela est possible quel serait le code?
Merci a vous
Yan












Avatar
Michel
bonjour,
il n'y a pas si longtemps j'avais pose une question similaire...
par conrtre a pres l'ouverture du documen, j'arrive a fermer le doc mais pas
l'application en elle meme.
Je ne travaille que avec word et pdf. le truc application.close ne marche
pas.. :o(
Une idee peut etre ?
Merci
@+
Michel.



"Daniel.j" wrote in message
news:
oui en effet avec cette variante (pour plus de facilité)
================= > Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal fsShowCmd As Long) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Const SW_SHOWNORMAL = 1

Function StartDoc(DocName As String) As Long
Dim Scr_hDC As Long
Scr_hDC = GetDesktopWindow()
StartDoc = ShellExecute(Scr_hDC, "Open", DocName, _
"", "C:", SW_SHOWNORMAL)
End Function

Sub Test()
Dim r As Long
' r = StartDoc("C:ajeterformation.doc")
' r = StartDoc("C:ajetervbnet.pdf")
StartDoc ("http://dj.joss.free.fr")
'StartDoc ("C:WINDOWSsystem32ssmarque.scr")
End Sub


--
Daniel
FAQ MPFE
http://dj.joss.free.fr/faq.htm

VBAXL
http://dj.joss.free.fr/

"yan" a écrit dans le message de news:
47db9531$0$852$
Re bonjour
Je viens d'essayer c'est parfait je te remercie. Mes connaissances
actuelles ne me permettent pas de comprendre ce code mais l'essentiel
c'est qu'il fonctionne
Est ce que d'une façon plus générale ce code permet d'ouvrir n'importe
quel type de fichier ( pdf,doc,dwg,....)
encore merci
bon week-end
yan


"Daniel.j" a écrit dans le message de news:

Bonjour
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
Private Const SW_SHOWNORMAL As Long = 1
Sub test()
ShellExecute hwnd, "open", "C:tonfichier.pdf", vbNullString,
vbNullString, SW_SHOWNORMAL
End Sub

--
Daniel
FAQ MPFE
http://dj.joss.free.fr/faq.htm

VBAXL
http://dj.joss.free.fr/


"yan" a écrit dans le message de news:
47db67be$0$844$
Bonjour à tous
Est-il possible a l'aide d'une procédure vba d'ouvrir un fichier
acrobat (pdf).
J'ai une procédure qui le fait pour des fichiers "word" mais je
n'arrive pas a le transposer pour acrobat
Si cela est possible quel serait le code?
Merci a vous
Yan