Option Explicit Dim strFiles(100) As String Dim filecount As Long Sub addFiles() Dim SrcFile As String Dim SrcFileList As String Dim filePath As String Dim counter As Long Dim nextPos As Long On Error GoTo erreur: cd.ShowOpen filePath = cd.FileName SrcFileList = Right(filePath, Len(filePath) - InStrRev(filePath, "")) filePath = Left(filePath, InStrRev(filePath, "")) If SrcFileList = "" Then Exit Sub If Left(SrcFileList, 1) = " " Then nextPos = 0 Do nextPos = nextPos + InStr(Mid(SrcFileList, nextPos + 1, Len(SrcFileList)), Chr(32)) If InStr(Mid(SrcFileList, nextPos + 1, Len(SrcFileList)), Chr(32)) <> 0 Then SrcFile = Mid(SrcFileList, nextPos + 1, InStr(Mid(SrcFileList, nextPos + 1, Len(SrcFileList)), Chr(32))) Else SrcFile = Mid(SrcFileList, nextPos + 1, Len(SrcFileList)) End If filecount = filecount + 1 strFiles(filecount) = filePath & SrcFile List1.AddItem Dir(filePath & SrcFile) Loop Until InStr(Mid(SrcFileList, nextPos + 1, Len(SrcFileList)), Chr(32)) = 0 Else List1.AddItem Dir(cd.FileName) filecount = filecount + 1 strFiles(filecount) = cd.FileName End If cd.FileName = "" Exit Sub erreur:: MsgBox Err.Description, , "Erreur" cd.FileName = "" End Sub Private Sub Command1_Click() addFiles End Sub Private Sub Form_Load() With cd .DialogTitle = "Encoder : fichier source" .DefaultExt = "*.*" .Filter = "Tout fichiers|*.*" .InitDir = App.Path .Flags = cdlOFNAllowMultiselect Or cdlOFNFileMustExist End With End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question