(Solved) – Receive Run-time Error 58 File Already Exists When It Doesn’t

  • by
(solved)-–-receive-run-time-error-58-file-already-exists-when-it-doesn’t

I keep on receiving “Run-time Error 58 File Already Exists” when trying to run the below code. I’ve double and triple checked and the file definitely doesn’t exist.

I run a different Macro first that gets me the location of the folder I want to create this new folder in. The location is displayed in ActiveWorkbook.Sheets(1).Range("A1"). Master File is the name of the new folder I want to create.

Sub CreateFolder

Dim Bname As String
Bname = ActiveWorkbook.Sheets(1).Range("A1").Text & "Master File"
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateFolder "Bname"

End Sub

I’ve also tried the following:

Sub CreateFolder

Dim Bname As String
Bname = ActiveWorkbook.Sheets(1).Range("A1").Text & "Master File"
MkDir "Bname"

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *