SaveAs

B

blerman

I have created the following macro, which is supposed to save the file based
on values in specific cells and then exit Excel, but it needs to be modified
to not save the file if the users clicks on the cancel button in the SaveAs
dialog box. I am a novice when it comes to this so any assistance with
specific examples will be greatly appreciated.

Sub saveexit()
'
' saveexit1 Macro
' Macro recorded 03/31/2008 by Barry Lerman
'
'
With ActiveWindow
strDate = Range("d2")
strDate1 = Format(Range("L2"), "mm-dd-yy")
Application.Dialogs(xlDialogSaveAs).Show _
arg1:=ActiveWorkbook.Path & "\" & strDate & " - " & "PPE" & " " & strDate1 &
" " & "T&A Worksheet", arg2:=1
ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
Application.Quit
ThisWorkbook.Close SaveChanges:=True

End With
End Sub
 
M

Malik

Hi,

Try this:
' Please change this line
If
Application.Dialogs(xlDialogSaveAs).Show(arg1:=ActiveWorkbook.Path & _
"\" & strDate & " - " & "PPE" & " " & strDate1 & " " & "T&A
Worksheet", arg2:=1) = True Then
ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
Application.Quit
ThisWorkbook.Close SaveChanges:=True
End If

*** Cancel button will return FALSE ***
 

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

Top