The VBA code below is supposed to do the following : If a workbook file with the SavedSourcePath name exists then Open it then Close it then suppress it. It opens it correctly, but do not close it and I get an error "index is outside the (?)list (tableau in french)
Note that at beginning I don't know if the file exists and if so if it is open or close. I want in every case it to disappear.
SavedSourcePath = "/Users/Shared/TS1/optim.xlsm"••••ˇˇˇˇ
If Dir(SavedSourcePath) <> "" Then
Workbooks.Open (SavedSourcePath)
Workbooks(SavedSourcePath).Close saveChanges:=False
Kill Workbooks(SavedSourcePath)
End If
Alternatively is there a way to save a workbook with a name which may exists and crash the previous one if it exists ? Witout having to answer a "do you want to…"