Bonjour
J'ai l'habitude d'utiliser le code suivant pour ouvrir tous les fichiers d'un répertoire pour aller y pecher des informations. Tout fonctionne sur mon poste avec excel 2003 mais sur mon poste avec excel 2007 l'instruction lookin ne fonctionne pas :
Dim lCount As Long
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Sheets("test").Select
On Error Resume Next
Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
'Change path to suit
.LookIn = "c:\local\test2"
.Filename = "* - dossier fiscal 2008.xls"
.FileType = msoFileTypeExcelWorkbooks
.Execute (msoSortByFileName)
'.Filename = "Book*.xls"
If .Execute > 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count 'Loop through all.
'Open Workbook x and Set a Workbook variable to it
Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
Sheets(1).Select
....
Merci de m'aider
J'ai l'habitude d'utiliser le code suivant pour ouvrir tous les fichiers d'un répertoire pour aller y pecher des informations. Tout fonctionne sur mon poste avec excel 2003 mais sur mon poste avec excel 2007 l'instruction lookin ne fonctionne pas :
Dim lCount As Long
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Sheets("test").Select
On Error Resume Next
Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
'Change path to suit
.LookIn = "c:\local\test2"
.Filename = "* - dossier fiscal 2008.xls"
.FileType = msoFileTypeExcelWorkbooks
.Execute (msoSortByFileName)
'.Filename = "Book*.xls"
If .Execute > 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count 'Loop through all.
'Open Workbook x and Set a Workbook variable to it
Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
Sheets(1).Select
....
Merci de m'aider