0

I try to list specific file name from directory. but I got error code 53 with Getattr function.

In my case, error occurred when file path & file name length is greater than 259 in same directory.

Question is

  1. how much length does Getattr function support?
  2. how can i solve this error?
  • Does this answer your question? [Is there a way for DIR(path) in VBA to handle strings longer than 260?](https://stackoverflow.com/questions/14720710/is-there-a-way-for-dirpath-in-vba-to-handle-strings-longer-than-260) – Pirate Mar 13 '20 at 04:48

1 Answers1

0
  1. I have not found this on official website. But i have tested it and it is working fine till length is 260.
  2. You can use relative path of directory.

Or

You can Prefix a path with \\?\, like \\?\C:\TEST\test.txt. This will convert DOS path names to native OS path names. Refer this.

Dim file_path = "\\?\C:\TEST\test.txt"
Naveen Kumar
  • 1,988
  • 1
  • 7
  • 11
  • Thank you for your reply. I also tested GetAttr function again in Excel VBA. But I also get Error. I posted my test result of Excel VBA debug.Print. Error#: 0 Desc: Error file path: D:\Temp\Temperatu0\Temperatu0Temperatu1\Temperatu0Temperatu2\Temperatu0Temperatu3\Temperatu0Temperatu4\Temperatu0Temperatu5\Temperatu0Temperatu6\Temperatu0Temperatu7\Temperatu0Temperatu8\Temperatu0Temperatu9\Temperatu0Temperat10\ --> length is 229 byte. – Seok Kim Mar 14 '20 at 21:50