1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| Sub liaison()
Dim classeurDate As Workbook, classeurCourant As Workbook, cellule As Range, nomFichier As String, applicationInvisible As New Excel.Application
Application.ScreenUpdating = False
applicationInvisible.Visible = False
Set classeurCourant = ActiveWorkbook
For Each cellule In classeurCourant.Worksheets(1).Rows(1).Cells()
If cellule.Value = vbNullString Then Exit For
nomFichier = classeurCourant.Path & "\" & cellule.Text & ".xls"
If Dir(nomFichier) <> vbNullString Then
Set classeurDate = applicationInvisible.Workbooks.Add(nomFichier)
cellule.Offset(1, 0).Value = classeurDate.Worksheets(1).Range("A1").Value
classeurDate.Close SaveChanges:=False
End If
Next cellule
applicationInvisible.Quit
Set applicationInvisible = Nothing
Application.ScreenUpdating = True
End Sub |
Partager