Sub Macro_facture_clients() ' ' Macro_facture_clients Macro ' Macro enregistrée le 21/08/02 par Jonckers Pascal ' ' Touche de raccourci du clavier: Ctrl+s ' Dim nfiledoc As Integer Dim indice As Integer Dim RetVal Dim filename As String Dim asGuillemet As String Dim filenameExt As String Dim MaLigne As Long Dim MaCol As Long Dim nPosExt As Integer Dim MaCell As Range Dim files, d, s Dim extention As String Set MaCell = ActiveCell MaCol = MaCell.Column MaLigne = MaCell.Row filename = Cells(MaLigne, 1) nfiledoc = 1 Set fs = Application.FileSearch With fs .NewSearch .FileType = msoFileTypeAllFiles .SearchSubFolders = True .filename = filename .LookIn = "P:\ES TECHNIK\factures clients\" If .Execute > 0 Then ' MsgBox "There were " & .FoundFiles.Count & _ ' " file(s) found." For i = 1 To .FoundFiles.Count ' MsgBox .FoundFiles(i) indice = i Next i Else ' MsgBox "There were no files found." End If Set files = CreateObject("Scripting.FileSystemObject") ' Set d = files.GetDrive(files.GetDriveName(.FoundFiles(indice))) extention = files.GetExtensionName(.FoundFiles(indice)) asGuillemet = """" If (extention = "doc") Then ' MsgBox asGuillemet + .FoundFiles(indice) + asGuillemet MyAppID = Shell("winword.exe " + asGuillemet + .FoundFiles(indice) + asGuillemet, vbMaximizedFocus) Else If (extention = "xls") Then ' MsgBox asGuillemet+.FoundFiles(indice)+asGuillemet + " xls " MyAppID = Shell("excel.exe " + asGuillemet + .FoundFiles(indice) + asGuillemet, vbMaximizedFocus) Else If (extention = "pdf") Then MsgBox .FoundFiles(indice) ' rechercher chemin complet pour acrobat reader MyAppID = Shell("AcroRd32.exe " + asGuillemet + .FoundFiles(indice) + asGuillemet, vbMaximizedFocus) Else If (extention = "txt") Then ' MsgBox .FoundFiles(indice) MyAppID = Shell("notepad.exe " + asGuillemet + .FoundFiles(indice) + asGuillemet, vbMaximizedFocus) Else If (extention = "dwg") Then MsgBox .FoundFiles(indice) + " pas de traitement pour ce fichier " Else If (extention = "tif") Then MsgBox .FoundFiles(indice) + " pas de traitement pour ce fichier " Else MsgBox .FoundFiles(indice) + " pas de traitement pour ce fichier " End If End If End If End If End If End If End With End Sub