anthosss
10-05-2017, 12:01 AM
Hello,
I am inside a folder doing the following:
1- i am checking if a folder named "no_links" exists or not
2- if folder "no_links" doesn't exist i am simply creating the folder
3- if folder "no_links" exists, i am checking if it contains any files. If there are files so i delete them then i delete the folder and i try to create again the folder named "no_links" and here i get the error "Run-time error '75': path/file access error"
I click on the end then i must go to the main folder where the folder "no_links" still showing and i must do a refresh ao the folder "no_links" disapear to be able to create it again.
Here is my code:
Dim strPath as String
strPath = ThisWorkbook.Path & "\"
Dim strFld as String
strFld = strPath & "no_links\"
Dim oFld as Object
Dim oFle as Object
If Dir(strFld, vbDirectory) <> "" Then
Set oFld = CreateObject("Scripting.FileSystemObject").GetFolder(strFld)
If Dir(strFld & "\*") <> "" Then
For Each oFle in oFld.Files
Kill(oFle.Path)
Next
End If
Set oFle = Nothing
Set oFld = Nothing
RmDir (strFld)
MkDir (strFld) 'on this command line i get the error
Else
MkDir (strFld)
End If
Thank you
I am inside a folder doing the following:
1- i am checking if a folder named "no_links" exists or not
2- if folder "no_links" doesn't exist i am simply creating the folder
3- if folder "no_links" exists, i am checking if it contains any files. If there are files so i delete them then i delete the folder and i try to create again the folder named "no_links" and here i get the error "Run-time error '75': path/file access error"
I click on the end then i must go to the main folder where the folder "no_links" still showing and i must do a refresh ao the folder "no_links" disapear to be able to create it again.
Here is my code:
Dim strPath as String
strPath = ThisWorkbook.Path & "\"
Dim strFld as String
strFld = strPath & "no_links\"
Dim oFld as Object
Dim oFle as Object
If Dir(strFld, vbDirectory) <> "" Then
Set oFld = CreateObject("Scripting.FileSystemObject").GetFolder(strFld)
If Dir(strFld & "\*") <> "" Then
For Each oFle in oFld.Files
Kill(oFle.Path)
Next
End If
Set oFle = Nothing
Set oFld = Nothing
RmDir (strFld)
MkDir (strFld) 'on this command line i get the error
Else
MkDir (strFld)
End If
Thank you