0

I'm trying to save a file and if it already exists, I'd like to overwrite it... I've looked on the documentation for .SaveAs and I'm not sure I'm understanding, I thought it'd be under the ConflictResolution:= but I can't seem to find it under there. I want it to not inform the user that it is overwriting the file as well as this is just a temporary saved file

ActiveWorkbook.SaveAs FileName:=SaveFilePath & "\FILE.xls", FileFormat:=51
Maldred
  • 1,074
  • 4
  • 11
  • 33

1 Answers1

4

What I typically do in this scenario is just check to see if it exists already, and if it does, delete it...

If Dir(sFilename) <> "" Then Kill sFilename
braX
  • 11,506
  • 5
  • 20
  • 33
  • You're a god's send, this works great! – Maldred Oct 26 '17 at 22:02
  • 2
    Keep in mind that if the file is currently open this will throw an exception, but just trying to overwrite it when it's open will also throw an exception. – braX Oct 26 '17 at 22:04
  • Yea, I saw that too... It's a little unfortunate, but it still works for my situation as the file is closed and only in rare cases will it ever be used again. Just need a temporary save location so I can attach it to an email and send it off after some edits were made – Maldred Oct 26 '17 at 22:08
  • I have came to this thread would like to know if there is a away to save as and over write and still work if the excel file is opened for a bit – Funny Memo Ms May 26 '23 at 19:57