Hi guys
I have the below code, but I am getting a mismatch error on line 11. Any ideas? I'm a newbie to all this so it's got me stumped!
Thanks,
Gareth
I have the below code, but I am getting a mismatch error on line 11. Any ideas? I'm a newbie to all this so it's got me stumped!
Code:
Sub GetLatestFiles() Dim strDir As String, fs As Object, startFolder As String, subfolder As Object, increment As Integer, latest As Integer, latestFolder As String
Set fs = CreateObject("Scripting.FileSystemObject")
startFolder = "H:\Everyone\SOFTCON PCS"
Set folder = fs.GetFolder(startFolder)
latest = 0
latestFolder = vbNullString
For Each subfolder In folder.SubFolders
increment = CInt(VBA.Right(subfolder.Path, Len(subfolder.Path) - WorksheetFunction.Find("-", subfolder.Path, 1)))
If increment > latest Then
latest = increment
latestFolder = subfolder.Path
End If
Next
Workbooks.Open latestFolder & "\" & "EGBCIS13.txt"
End Sub
Thanks,
Gareth