ticrain
Messages postés178Date d'inscriptionjeudi 15 mars 2007StatutMembreDernière intervention 2 janvier 2015
-
24 avril 2007 à 09:11
drikce06
Messages postés2236Date d'inscriptionlundi 29 mai 2006StatutMembreDernière intervention29 mai 2008
-
26 avril 2007 à 16:04
Bonjour,
J'aimerai ouvrir des fichiers choisi dans une listbox. Problème c'est que dans une listbox nous faisons apparaître des cellules, et non directements des fichiers comment puige faire pour faire corresponsdre le texte de ma cellule avec celui de mon fichier? Merci beaucoup!
ticrain
Messages postés178Date d'inscriptionjeudi 15 mars 2007StatutMembreDernière intervention 2 janvier 2015 26 avril 2007 à 15:55
Voici ce que j'ai et rien ne se passe quand je clique sur ma listbox:
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_MAXIMIZE = 3
Private Sub listbox1_Click()
Dim nomdoc As String
nomdoc = ListBox1.List(ListBox1.ListIndex)
Call ShellExecute(0, "open", nomdoc, vbNullString, "C:", SW_SHOWNORMAL)
End Sub
Private Sub user_activate()
Dim Fichier As String
Dim Repertoire As String
Repertoire = "C:"
Fichier = Dir(Repertoire & "*.*")
While Fichier <> ""
Call ListBox1.AddItem(Repertoire & Fichier)
Fichier = Dir
Wend
End Sub
jrivet
Messages postés7392Date d'inscriptionmercredi 23 avril 2003StatutMembreDernière intervention 6 avril 201260 26 avril 2007 à 16:00
Question ?
Est ce que ta listbox contient des nom de fichiers car si elle en possède c'est pas grace à ce code
Moi je te propose
Private Sub UserForm_Activate()
et Private Sub User_Activate() (qui devient juste une procédure ou l'événement d'un objet nommé USER)
drikce06
Messages postés2236Date d'inscriptionlundi 29 mai 2006StatutMembreDernière intervention29 mai 200810 26 avril 2007 à 16:02
De plus le code de jrivet marche nickel je viens de le tester
Option Explicit
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_MAXIMIZE = 3
Private Sub ListBox1_Click()
Dim Fichier As String
Fichier = ListBox1.List(ListBox1.ListIndex)
Call ShellExecute(0, "open", Fichier, vbNullString, vbNullString, SW_MAXIMIZE)
End Sub
Private Sub UserForm_Activate()
Dim Fichier As String
Dim Repertoire As String
Repertoire = "C:"
Fichier = Dir(Repertoire & "*.*")
While Fichier <> ""
Call ListBox1.AddItem(Repertoire & Fichier)
Fichier = Dir
Wend
End Sub
Drikce 06
Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas: