Addendum:
Public Sub Clean_directory(Directory As String)
Dim fso As FileSystemObject, fileList As Folder,
_singleFile As File
Set fso = CreateObject("Scripting.FileSystemObject")
Set fileList = fso.GetFolder(Directory)
For Each singleFile In fileList.Files...
I have added Reference to MSR. Thanks for suggestion.
How about this shorter alternative for Sub Clean_directory?
Are variables fileList and File both type FileSystemObject?
Public Sub Clean_directory(Directory As String)
Dim fso As FileSystemObject, fileList As FileSystemObject, File As...
Thanks Glasgow and Swi,
I used the first code block, since it will delete a folder and its contents, but did not use the 'True' option.
Dim fso As FileSystemObject
should be:
Dim fso
I will never use Kill or RmDir ever again.
Timing is not the problem. I break on the RmDir line and then press F8 to execute it, after a slight pause.
Executing the RmDir command from the intermediate window invokes the same error. All Directories are read-only, and changing that attribute does not solve the problem.
I may try...
Strange,
When I comment out the call to Clean_directory, and ensure the directory is empty, the RmDir works. Somehow the Sub Clean_directory is the source of my ills.
Call Clean_directory(CMC_Path & path(j) & "\")
RmDir CMC_Path & path(j)
''''''''''''''''''''''''''''''''''''''''''''''''''...
The Directory I am trying to remove is:
CMC_Path & path(j)
where strings:
CMC_Path = "c:\iofs_pom\cmc\"
path(j) = "2004010112"
Neither string contains any spaces.
The directory is empty.
Hi,
The office has finally upgraded from Win98 to XP. Now my VB code which worked perfectly under Win98 fails when executing the RmDir command. The Kill command works fine.
Is this a security problem? I have admin privileges and own the directory to be removed.
Thanks,
Brendan
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.