ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dir("D:\") refresh problem (https://www.excelbanter.com/excel-programming/322906-re-dir-d-%5C-refresh-problem.html)

Jake Marx[_3_]

Dir("D:\") refresh problem
 
Hi Alex,

If you don't specify that you're looking for a directory, Dir() will return
the name of the first file found in that folder. So in this case, I'm
assuming that D:\temp\alex\ contains at least one file and that D:\temp\
only contains folders.

You could use this instead:

If Len(Dir$("D:\temp\alex\", vbDirectory)) Then

and

If Len(Dir$("D:\temp\", vbDirectory)) Then


These statements should return True if the folders exist and False if they
don't exist.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Alex St-Pierre wrote:
Hello,
The Dir function doesn't work all the time
example:
If Dir("D:\temp\alex\") = "" Then
exit sub
endif
the macro doesn't stop because the repertory is valid

and then, I try:
If Dir("D:\temp\") = "" Then
exit sub
endif
and the macro stop ?

It's very strange, the drive used is a server drive but always
available.

Finally, I tried:
path = "D:\temp\"
ChDrive path
ChDir path
If Dir(path) = "" Then
exit sub
endif
ChDrive and ChDir change but the macro stop ??
Any idea ?
Thanks,



Alex St-Pierre

Dir("D:\") refresh problem
 
Thanks a lot, i used:
If Len(Dir$("D:\temp\", vbDirectory))=0 Then
end if
"Jake Marx" wrote:

Hi Alex,

If you don't specify that you're looking for a directory, Dir() will return
the name of the first file found in that folder. So in this case, I'm
assuming that D:\temp\alex\ contains at least one file and that D:\temp\
only contains folders.

You could use this instead:

If Len(Dir$("D:\temp\alex\", vbDirectory)) Then

and

If Len(Dir$("D:\temp\", vbDirectory)) Then


These statements should return True if the folders exist and False if they
don't exist.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Alex St-Pierre wrote:
Hello,
The Dir function doesn't work all the time
example:
If Dir("D:\temp\alex\") = "" Then
exit sub
endif
the macro doesn't stop because the repertory is valid

and then, I try:
If Dir("D:\temp\") = "" Then
exit sub
endif
and the macro stop ?

It's very strange, the drive used is a server drive but always
available.

Finally, I tried:
path = "D:\temp\"
ChDrive path
ChDir path
If Dir(path) = "" Then
exit sub
endif
ChDrive and ChDir change but the macro stop ??
Any idea ?
Thanks,





All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com