OVH Cloud OVH Cloud

Ouvrir un fichier

2 réponses
Avatar
Patrick FREDIN
Bonjour,

Dans un champ d'une table j'ai le nom complet d'un fichier
(path + nom) pour chaque enregistrement. Le type est
inconnu (Word, Excel, PDF, ...).

En cliquant sur un bouton je souhaite ouvrir ce fichier.
Quel code VB dois-je utiliser ?

Merci d'avance.

Patrick

2 réponses

Avatar
ng
Salut,

Essai ceci :

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
Const SW_SHOWNORMAL = 1

Private Sub Form_Load()
Dim sCheminComplet as String
sCheminComplet = "c:..."
ShellExecute Me.hwnd, "open" , sCheminComplet , vbNullString, "C:",
SW_SHOWNORMAL
End Sub


Nicolas.
--
http://www.ngsoft-fr.com
"Patrick FREDIN" a écrit dans le message de news:
07ca01c3cf12$c4092340$
Bonjour,

Dans un champ d'une table j'ai le nom complet d'un fichier
(path + nom) pour chaque enregistrement. Le type est
inconnu (Word, Excel, PDF, ...).

En cliquant sur un bouton je souhaite ouvrir ce fichier.
Quel code VB dois-je utiliser ?

Merci d'avance.

Patrick



Avatar
Pierre Alexis [MVP]
Salut Patrick,

Tu as écrit :

Dans un champ d'une table j'ai le nom complet d'un fichier
(path + nom) pour chaque enregistrement. Le type est
inconnu (Word, Excel, PDF, ...).

En cliquant sur un bouton je souhaite ouvrir ce fichier.
Quel code VB dois-je utiliser ?



Réponse sur la FAQ ;-) :

Question 8 - Comment ouvrir un fichier à partir d'une application VB ?
http://faq.vb.free.fr/index.php?question=8

--
Pierre ALEXIS - MVP Visual Basic
Courriel & messenger :
FAQ Visual Basic : http://faq.vb.free.fr/