FileSystemObject.GetFile() gets a “file not found” error if you call it on a filename with a single quote/apostrophe in it, ie:
FileSystemObject.GetFile("D:\somepath\some file with an ' apostrophe in it.txt")
Here’s what I’m attempting:
Public Sub VBA_GetFileInfo(FileName As String, ByRef outDateCreated As Date, ByRef outDateAccessed As Date, ByRef outDateModified As Date, ByRef outFileSize As Long)
Dim tmpFile As String
'SOME THINGS I'VE TRIED TO OVERCOME THE PROBLEM, WITH NO SUCCESS:
'tmpFile = """" & FileName & """"
'tmpFile = FileName
'tmpFile = Replace(tmpFile, "\", "\\")
'tmpFile = Replace(tmpFile, "'", "\'")
Dim fso As FileSystemObject
Dim f As file
Dim s As String
Set fso = New FileSystemObject
----> BLOWS UP HERE with "file not found" error:
Set f = fso.GetFile(tmpFile)
brettdj’s comment:
…turns out to have been the correct answer, it must have been apostrophe’s rather than single quotes causing the error.