Re : File search Excel 2007
oui effectivement je recherche un fichier commençant par planning prod, la suite est une date c'est pour sa que je fais un tri décroissant, car je souhaite sélectionner le plus vieux.
Pour que ce soit plus clair je joins mon code initial en entier:
Sub ImportPlanning()
Dim fsReport As filesearch
Dim X As Range
Dim wB3 As Workbook
Worksheets("Plages").Select
Range("N4").Select
Set X = Selection
Set fsReport = Application.filesearch
With fsReport
.LookIn = "C:\Users\Portable\Desktop\Planning Prod\"
.Filename = "planning prod*"
.FileType = msoFileTypeExcelWorkbooks
If .Execute(SortBy:=msoSortByFileName, sortorder:=msoSortOrderDescending) > 0 Then
For i = 1 To .FoundFiles.Count
If i > 1 Then
GoTo Fin
Else
End If
wB1 = .FoundFiles(i)
X.Value = FileDateTime(wB1)
Workbooks.OpenText Filename:=.FoundFiles(i)
wB2 = ActiveWorkbook.Name
If X.Value = X.Offset(0, -1) Then
If MsgBox("Le fichier" & " " & wB2 & " " & "blabla", vbYesNo) = vbYes Then
GoTo Suite
Else
ActiveWorkbook.Close False
MsgBox "blabla", vbExclamation
Workbooks("toto").Close False
End If
End If
Suite:
ActiveWorkbook.Close False
Workbooks("Taux").Activate
Application.DisplayAlerts = False
Worksheets("excel").Select
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
Workbooks.OpenText Filename:=.FoundFiles(i)
Set wB3 = ActiveWorkbook
Worksheets("excel").Select
Worksheets("excel").Copy Before:=Workbooks("Taux").Sheets(1)
wB3.Activate
wB3.Close False
Next i
Else
MsgBox "There were no files found."
End If
End With
Fin:
End Sub
Jusqu'à présent celà marchait très bien sous excel 2003, et pour une recherche de fichier semblable sur 2007, je n'y arrive pas. Merci d'avance pour votre aide.