Remember DOS? Back in the day, we had to limit our file names to eight characters plus a three digit extension (8.3) and we liked it. Today I needed to add Google Chrome to my startup batch file. Normally I can convert long Windows paths to short DOS paths in my head, but I couldn’t remember what do with spaces (just eliminate them), so I wrote this to figure out the short path.
Dim fso As Scripting.FileSystemObject
Dim fsoFile As Scripting.file
Set fso = New FileSystemObject
Set fsoFile = fso.GetFile(sPath)
GetShortDosPath = fsoFile.ShortPath
Don’t forget to set a reference to Microsoft Scripting Library (Tools – References)