Looping through folder with DIR ???

Really? :confused:

As pretty much all usage I have seen of that function does eaxctly that.

https://www.exceltrick.com/formulas_macros/vba-dir-function/

https://trumpexcel.com/vba-dir-function/

Plus I used your code to print out all the files in my temp folder without any issue.?


Yeah, it works nicely BUT you can NOT, while running through the files, use Dir() one more time.
Why do that, you say - in my case I was (wrongly !) running through Word-documents using Dir() and examine each of them for Hyperlinks to a local FILE - and here I used Dir() one more time to test if that file exists - this second use of Dir() screwed up the FIRST use of Dir() - that's why I said it looked like the "directory chain of files" were broken ... and it was, because of the SECOND use of Dir().


Hope you got it - english is NOT my first language :D
 
Yeah, it works nicely BUT you can NOT, while running through the files, use Dir() one more time.
Why do that, you say - in my case I was (wrongly !) running through Word-documents using Dir() and examine each of them for Hyperlinks to a local FILE - and here I used Dir() one more time to test if that file exists - this second use of Dir() screwed up the FIRST use of Dir() - that's why I said it looked like the "directory chain of files" were broken ... and it was, because of the SECOND use of Dir().


Hope you got it - english is NOT my first language :D
Hi. When I run into this type of problem, I dump Dir() and use FSO instead. Just my 2 cents...
 
Pardon me if I seem a little slow here, but were you using DIR() in loopThroughHyperlinks ?

If so, now I understand.?

Yeah, it works nicely BUT you can NOT, while running through the files, use Dir() one more time.
Why do that, you say - in my case I was (wrongly !) running through Word-documents using Dir() and examine each of them for Hyperlinks to a local FILE - and here I used Dir() one more time to test if that file exists - this second use of Dir() screwed up the FIRST use of Dir() - that's why I said it looked like the "directory chain of files" were broken ... and it was, because of the SECOND use of Dir().


Hope you got it - english is NOT my first language :D
 
Hi ksor. If you want to see an example of how to use FSO, let me know. Cheers!
 
i believe the Dir function does not work with Unicode characters inside file names
If you use the FileSystemObject, it will work better
 
i believe the Dir function does not work with Unicode characters inside file names
If you use the FileSystemObject, it will work better
Ah, good to know. Thanks!
 

Users who are viewing this thread

Back
Top Bottom