Dim sChemin As String
Dim sFich As String
sChemin = ThisWorkbook.Path & "\"
With Application.FileDialog(msoFileDialogFilePicker)
.InitialFileName = sChemin
.Title = "Sélectionner le fichier"
.AllowMultiSelect = False
.ButtonName = "Sélection Fichier"
With .Filters
.Clear
.Add "All", "*.*"
End With
.Show
If .SelectedItems.Count > 0 Then
sFichier = .SelectedItems(1)
sFich = sFichier
ListeProprietesFichier_getDetailsOf sFich
End If
End With
End Sub
Sub ListeProprietesFichier_getDetailsOf(Fichier As String)
'source:
'http://www.microsoft.com/resources/documentation/windows/2000/server/
'scriptguide/en-us/sas_fil_lunl.mspx
'
'Nécessite d'activer la référence Microsoft Shell Controls and Automation
'
Dim Fso As Object, oFichier As Object
Dim objShell As Shell32.Shell
Dim objFolder As Shell32.Folder
Dim strFileName As Shell32.FolderItem
Dim Chemin As String, NomFich As String, Resultat As String
Dim i As Byte
'-----
Set Fso = CreateObject("Scripting.FileSystemObject")
Set oFichier = Fso.GetFile(Fichier)
Chemin = Fso.GetParentFolderName(oFichier)
NomFich = Fso.GetFileName(oFichier)
'-----
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(Chemin)
Set strFileName = objFolder.Items.Item(NomFich)
For i = 0 To 34
'Cet exemple n'affiche pas les propriétés vides
If objFolder.GetDetailsOf(strFileName, i) <> "" Then _
Resultat = Resultat & objFolder.GetDetailsOf(objFolder.Items, i) _
& ": " & objFolder.GetDetailsOf(strFileName, i) & vbLf
Next
MsgBox Resultat
End Sub