Hi,
I have written the following code to have the user enter the date of the files they want to open and then to have all 4 files open.
The issue I have is how to check that all the files exist before opening any of them?
Please help
Regards Damian
I have written the following code to have the user enter the date of the files they want to open and then to have all 4 files open.
The issue I have is how to check that all the files exist before opening any of them?
Please help
Code:
Sub Import()
Dim D As String
Dim wb As Workbook
Dim File1 As String
Dim File2 As String
Dim File3 As String
Dim File4 As String
D = InputBox("Enter Date" & Chr(10) & Chr(10) & "Format DD-MM-YYYY", "Select File Date")
D = Format(D, "DD-MM-YYYY")
ChDir ("C:\Users\Damian\Desktop")
File1 = "71MM Packsheets - " & D
File2 = "86MM Packsheets - " & D
File3 = "Cluster Packsheets - " & D
File4 = "Natural Packsheets - " & D
With Workbooks.Open(Filename:=File1, ReadOnly:=True, UpdateLinks:=False)
End With
With Workbooks.Open(Filename:=File2, ReadOnly:=True, UpdateLinks:=False)
End With
With Workbooks.Open(Filename:=File3, ReadOnly:=True, UpdateLinks:=False)
End With
With Workbooks.Open(Filename:=File4, ReadOnly:=True, UpdateLinks:=False)
End With
End Sub
Regards Damian