cresbydotcom
Technical User
- May 22, 2006
- 234
Hi
detecting folders &/or files with spaces in their name
I just found a problem reading the file attributes when the object is a folder. By detecting an error this code then reads folder attributes.
However if there is a space in the file name the error is not trapped - but in a folder it does not cause the same error
Excel 2002, XP SP2
any ideas how to get file attributes if the file name has a space?
after this the file/folder attributes can be read (eg folder = 16)
detecting folders &/or files with spaces in their name
I just found a problem reading the file attributes when the object is a folder. By detecting an error this code then reads folder attributes.
However if there is a space in the file name the error is not trapped - but in a folder it does not cause the same error
Excel 2002, XP SP2
any ideas how to get file attributes if the file name has a space?
Code:
On Error GoTo fol
If InStr(1, docs, " ") < 1 Then Set f = fs.GetFile(docs): Range("O" & o).Value = docs: o = o + 1: GoTo fol2
fol: Set f = fs.GetFolder(docs): Range("N" & n).Value = docs: n = n + 1:
fol2: On Error GoTo 0
after this the file/folder attributes can be read (eg folder = 16)