Deliverable7
New Member
- Joined
- Apr 9, 2016
- Messages
- 33
Hi guys
I have a macro that pulls a file name and file path from cell within a sheet. The macro works well and when there is an existing file in the directory (with the same name) a dialog box pops up asking if I want to overwrite an existing file. If I select yes the macro works as intended. However when I select no to overwriting the existing file I get a Run-time error 1004:
Can someone please show me how to close the macro (prevent it from hanging) when selecting no to overwriting the existing file, a desired action would be to simply stop the macro.
[Option Explicit
Sub SaveShiftReport()
Dim FName As String
Dim FPath As String
FPath = Sheets("Day Shift").Range("AO1").Text
FName = Sheets("Day Shift").Range("AO2").Text
ThisWorkbook.SaveAs FileName:=FPath & "" & FName
On Error Resume Next
End Sub]
Thanks
I have a macro that pulls a file name and file path from cell within a sheet. The macro works well and when there is an existing file in the directory (with the same name) a dialog box pops up asking if I want to overwrite an existing file. If I select yes the macro works as intended. However when I select no to overwriting the existing file I get a Run-time error 1004:
Can someone please show me how to close the macro (prevent it from hanging) when selecting no to overwriting the existing file, a desired action would be to simply stop the macro.
[Option Explicit
Sub SaveShiftReport()
Dim FName As String
Dim FPath As String
FPath = Sheets("Day Shift").Range("AO1").Text
FName = Sheets("Day Shift").Range("AO2").Text
ThisWorkbook.SaveAs FileName:=FPath & "" & FName
On Error Resume Next
End Sub]
Thanks