I have been getting help on the MS forum about how to check a folder for files with a particular name. So far I have go to this:
Sub Checks()
Dim myNames As Variant
Dim wkbk As Workbook
Dim myPath As String
Dim iCtr As Long
Set something = Application.FileDialog(msoFileDialogFolderPicker)
MsgBox "Select the SystmOne GMS Files (Originals)", vbInformation
something.Show
somethingpath = CurDir()
myNames = Array("WORKBOOKONE.xls", "WORKBOOKEIGHT.xls", "WORKBOOKNINE.xls") 'you'd type in all 24 of those names
myPath = somethingpath 'or whatever you used to get the path
If Right(myPath, 1) <> "\" Then
myPath = myPath & "\"
End If
For iCtr = LBound(myNames) To UBound(myNames)
Set wkbk = Workbooks.Open(Filename:=myPath & myNames(iCtr))
'do stuff with wkbk
wkbk.Close savechanges:=False 'or true??
Next iCtr
End Sub
When a file is found, the script moves to the next file. But when one is not present in a folder, the macro stops. Rather than stopping/crashing, I would like a message box to show with a message e.g. "WORKBOOKNINE.xls Not Found". Then once the user clicks ok it will look for the next file.
Can anyone help?
Cheers
dvent
Bookmarks