I want to look in a folder and pull a list of all the files in that folder.
I found a snippet of code that does this and it sometimes works and sometimes not.
I think the issue may be because I need the path to be relative.
Here's the bit of relevant code. I get a 'path not found' runtime error on the last line.
The path in StrLoc is "..\Analysis & Testing\Analysis Reports\"
Dim oFSO As Object
Dim oFolder As Object
Dim oFile As Object
StrLoc = "..\" & Right(StrLoc, n) & "\Analysis Reports\"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(StrLoc)
Help would be appreciated. I cannot use a fixed path string as it changes depending on the user.
But I can say that the Excel file this is in is inside Analysis & Testing and so Analysis Reports is therefore a subfolder and this structure will always be the same.