Stopping error

  • Thread starter Thread starter XCESIV
  • Start date Start date
X

XCESIV

Below is a macro i have made that saves the file name like i want it too
using data from the worksheet. The problem is if they file name has
been used before, which it shouldnt have but could have accidently been
saved, it asks if you would like to save over this. if you click no
then it crashes.

Is it possible to set it that if u click no it just ends the macro.

thanks

Sub SAVEAS_NEW_FNE()
Dim FN As Workbook
Dim D As Variant
[D] = Format(Range("B3"), "mm_dd_yyyy")
ThisWorkbook.SaveAs Filename:="FNE " & [D]
End Sub
 
Sub SAVEAS_NEW_FNE()
Dim FN As Workbook
Dim D As Variant
Dim sFilename As String

[D] = Format(Range("B3"), "mm_dd_yyyy")
sFilename ="FNE " & [D]
If Len(Dir(sFilename)) = 0 Then
ThisWorkbook.SaveAs Filename:="FNE " & [D]
Else
Msgbox sFilename & " already exists"
End If
End Sub


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 
in a macro i have i open a 2nd workbook. when i try and get the macro
to close the file it asks to save yes/no

is there a way to stop it asking this question

Thanks
 
Use

Use the SaveChanges:=False option on the close.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

VBA Save 3
SAVE AS MACRO 6
Reference active worksheet from macro in personal.xls 2
BeforeSave 7
Private Sub Workbook_BeforeSave 2
BeforeSave Event 5
SAVE AS MACRO 4
Copy Data from Closed File to Existing File 0

Back
Top