1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
Private Sub Command1_Click()
Dim sFile As String, choisirtitre As String, choisirfiltre As String
choisirtitre = "Le_titre_qui_te_plait ici"
choisirfiltre = "fichiers images (.bmp,.jpg,.gif)" + Chr$(0) + "*.bmp;*.jpg*;*.*gif;*.tiff"
sFile = ShowMODE(Me, choisirtitre, choisirfiltre)
If sFile = "" Then
MsgBox "tu n'as pas choisi de fichier ! et alors ?"
Exit Sub
Else
MsgBox sFile '<<<========= sFile est ce que tu dois récupérer dans ton code
End If
End Sub
Public Function ShowMODE(forma As Form, queltitre, quelfiltre) As String
Dim OFName As OPENFILENAME
OFName.lStructSize = Len(OFName): OFName.hwndOwner = forma.hWnd
OFName.hInstance = App.hInstance: OFName.lpstrFilter = quelfiltre
OFName.lpstrFile = Space$(254)
OFName.nMaxFile = 255
OFName.lpstrFileTitle = Space$(254)
OFName.nMaxFileTitle = 255
If lastpath = "" Then lastpath = "c:\"
OFName.lpstrInitialDir = lastpath
OFName.lpstrTitle = queltitre
OFName.Flags = 0
If GetOpenFileName(OFName) Then
ShowMODE = Trim$(OFName.lpstrFile)
lastpath = detchemin(ShowMODE)
End If
End Function
Public Function detchemin(z0 As String) As String
'pour extraire d'un nom de chemin complet le nom du seul chemin de répertoire
Dim i As Integer, j As Integer
i = 0
j = 0
i = InStr(z0, "\")
Do While i <> 0
j = i: i = InStr(j + 1, z0, "\")
Loop
If j = 0 Then
detchemin = ""
Else
detchemin = Left$(z0, j)
End If
End Function |
Partager