Is there a way to automatically ID a drive. Sometimes when I put my USB flash drive in my computer it can be either a G drive, H drive or E drive. My program is set up to save my program results on the H drive. So if the computer ID's the drive as something else I have to manually edit the macro. Is there a way to solve this?
Code:
Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
'Change path to suit
'.LookIn = "F:\Investments\Summary\Daily_A"
'.LookIn = "G:\Investments\Summary\Daily_A"
.LookIn = "H:\Investments\Summary\Daily_A"
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count 'Loop through all files.
'Open Workbook x and Set a Workbook variable to it
Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
'ActiveWindow.WindowState = xlMinimized
Call BulkQuotesXL.UpdateData
Set wbCodeBook = ThisWorkbook
R1 = ActiveSheet.UsedRange.Rows.Count
R2 = "F" & R1
SR = R1 - 22
ActiveWindow.ScrollRow = SR
Range(R2).Select
End Select
End With
Next
wbResults.Close SaveChanges:=True
Next lCount
' End If
End If
End With
On Error GoTo 0
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
'
End Sub