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

Affichier un fichier PDF

4 réponses
Avatar
Michel
Bonjour à tous,

J'ai un petit problème dans une appli VB6

Je souhaite faire afficher un fichier PDF qui se trouve sur mon disque dur.

Comment faire ouvrir Acrobat Reader et afficher mon fiochier xxx.pdf ???

J'ai essayer d'utiliser l'ocx acrobat mais je n'ai pas l'impression que ça
réponde à mon besoin ou alors je ne sais pas l'utiliser..

Grand merci !

Cordialement,

Michel

4 réponses

Avatar
jean-marc
"Michel" wrote in message
news:#
Bonjour à tous,

J'ai un petit problème dans une appli VB6

Je souhaite faire afficher un fichier PDF qui se trouve sur mon disque


dur.

Comment faire ouvrir Acrobat Reader et afficher mon fiochier xxx.pdf ???

J'ai essayer d'utiliser l'ocx acrobat mais je n'ai pas l'impression que ça
réponde à mon besoin ou alors je ne sais pas l'utiliser..



Hello,

Le plus simple, c'est avec ShellExecute, qui va ouvrir le pdf
avec le programme qui lui est associé (en général Acrobat Reader):

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

Private Sub Command1_Click()
Dim s As String

' par exemple un document word
s = "c:truc.pdf"

ShellExecute hwnd, "open", s, vbNullString, vbNullString,
SW_SHOWNORMAL

Ceci fonctionne pour autant que Acrobat Reader soit
bien installé sur le poste client.

--
Jean-marc
Avatar
Le pape
Pour être sûr qu'un reader est installé :


Private Function TrimNull(item As String)

'Nettoie la chaine en enlevant les nulls

Dim pos As Integer

pos = InStr(item, Chr$(0))

If pos Then
TrimNull = Left$(item, pos - 1)
Else: TrimNull = item
End If

End Function


Private Function GetReaderName(dwFlagReturned As Long) As String
Dim hFile As Long
Dim sResult As String
Dim sTempFolder As String

'Choisir un répertoire quelconque
sTempFolder = "c:"

'create a dummy pdf file in the temp dir
hFile = FreeFile
Open sTempFolder & "dummy.pdf" For Output As #hFile
Close #hFile

'Récupérer le fichier et son path*
' Définir par exemple une constante MAX_PATH = 255
sResult = Space$(MAX_PATH)
dwFlagReturned = FindExecutable("dummy.pdf", sTempFolder, sResult)

'clean up
Kill sTempFolder & "dummy.html"

'Renvoi résultat
GetReaderName = TrimNull(sResult)

End Function

Philippe


jean-marc a écrit :
"Michel" wrote in message
news:#
Bonjour à tous,

J'ai un petit problème dans une appli VB6

Je souhaite faire afficher un fichier PDF qui se trouve sur mon disque


dur.
Comment faire ouvrir Acrobat Reader et afficher mon fiochier xxx.pdf ???

J'ai essayer d'utiliser l'ocx acrobat mais je n'ai pas l'impression que ça
réponde à mon besoin ou alors je ne sais pas l'utiliser..



Hello,

Le plus simple, c'est avec ShellExecute, qui va ouvrir le pdf
avec le programme qui lui est associé (en général Acrobat Reader):

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

Private Sub Command1_Click()
Dim s As String

' par exemple un document word
s = "c:truc.pdf"

ShellExecute hwnd, "open", s, vbNullString, vbNullString,
SW_SHOWNORMAL

Ceci fonctionne pour autant que Acrobat Reader soit
bien installé sur le poste client.

--
Jean-marc






Avatar
Michel69
Merci à tous les 2...

ça fonctionne !!

Michel


"jean-marc" a écrit dans le message de news:
43f9ae64$0$14128$
"Michel" wrote in message
news:#
Bonjour à tous,

J'ai un petit problème dans une appli VB6

Je souhaite faire afficher un fichier PDF qui se trouve sur mon disque


dur.

Comment faire ouvrir Acrobat Reader et afficher mon fiochier xxx.pdf ???

J'ai essayer d'utiliser l'ocx acrobat mais je n'ai pas l'impression que
ça
réponde à mon besoin ou alors je ne sais pas l'utiliser..



Hello,

Le plus simple, c'est avec ShellExecute, qui va ouvrir le pdf
avec le programme qui lui est associé (en général Acrobat Reader):

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

Private Sub Command1_Click()
Dim s As String

' par exemple un document word
s = "c:truc.pdf"

ShellExecute hwnd, "open", s, vbNullString, vbNullString,
SW_SHOWNORMAL

Ceci fonctionne pour autant que Acrobat Reader soit
bien installé sur le poste client.

--
Jean-marc






Avatar
Jean-Marc
Merci du retour d'info :-)

--
Jean-marc
Tester mon serveur (VB6) => http://myjmnhome.dyndns.org
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;


"Michel69" a écrit dans le message de
news:
Merci à tous les 2...

ça fonctionne !!

Michel


"jean-marc" a écrit dans le message de news:
43f9ae64$0$14128$
> "Michel" wrote in message
> news:#
>> Bonjour à tous,
>>
>> J'ai un petit problème dans une appli VB6
>>
>> Je souhaite faire afficher un fichier PDF qui se trouve sur mon


disque
> dur.
>>
>> Comment faire ouvrir Acrobat Reader et afficher mon fiochier


xxx.pdf ???
>>
>> J'ai essayer d'utiliser l'ocx acrobat mais je n'ai pas l'impression


que
>> ça
>> réponde à mon besoin ou alors je ne sais pas l'utiliser..
>
> Hello,
>
> Le plus simple, c'est avec ShellExecute, qui va ouvrir le pdf
> avec le programme qui lui est associé (en général Acrobat Reader):
>
> 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
>
> Private Sub Command1_Click()
> Dim s As String
>
> ' par exemple un document word
> s = "c:truc.pdf"
>
> ShellExecute hwnd, "open", s, vbNullString, vbNullString,
> SW_SHOWNORMAL
>
> Ceci fonctionne pour autant que Acrobat Reader soit
> bien installé sur le poste client.
>
> --
> Jean-marc
>
>
>
>