Result:
Option Explicit
Sub Checks()
Dim myNames As Variant
Dim wkbk As Workbook
Dim myPath As String
Dim iCtr As Long
MsgBox "Select the SystmOne GMS Files (Originals)", vbInformation
With Application.FileDialog(msoFileDialogFolderPicker)
' Optional: set folder to start in
.InitialFileName = "C:\my documents\excel\"
.Title = "Select the folder to process"
If .Show = True Then
myPath = .SelectedItems(1)
'add trailing backslash
myPath = myPath & "\"
Else
MsgBox "Try later!"
Exit Sub
End If
End With
myNames = Array("WORKBOOKONE.xls", _
"WORKBOOKEIGHT.xls", _
"WORKBOOKNINE.xls")
For iCtr = LBound(myNames) To UBound(myNames)
Set wkbk = Nothing
On Error Resume Next
Set wkbk = Workbooks.Open(Filename:=myPath & myNames(iCtr))
On Error GoTo 0
If wkbk Is Nothing Then
MsgBox myPath & myNames(iCtr) & " was not opened!" & vbLf & _
"Maybe it doesn't exist???"
Else
'do stuff with wkbk
MsgBox wkbk.Worksheets(1).Range("a1").Text
wkbk.Close savechanges:=False 'or true??
End If
Next iCtr
End Sub
Bookmarks