I have the following code to create and save a new workbook. If there is a file that is already open by the same name, I get an error.
Is there a way I can force it to close the open file and automatically overwrite the previous file with the same name?
Where DirPath is string indicating the path of the file and WBname is the name of the file.
ActiveWorkbook.SaveAs Filename:=DirPath & WBName & ".xlsx", FileFormat:=51
Is there a way I can force it to close the open file and automatically overwrite the previous file with the same name?
Where DirPath is string indicating the path of the file and WBname is the name of the file.
ActiveWorkbook.SaveAs Filename:=DirPath & WBName & ".xlsx", FileFormat:=51