If SaveCopy is canceled, exit sub

Excel Jr

New Member
Joined
Aug 17, 2018
Messages
26
Hi,

I know how to test a defined variable, but for the life of me I can't figure out how to test whether a user follows through the SaveAs prompt that I'm calling below:

Code:
    [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=If]#If[/URL]  Mac Then
    
        MsgBox "Please save the file somewhere it can easily be found, such as your desktop. You must save the file as a ""Macro-enabled Worksheet(.xlsm)"" file type, otherwise it will be unreadable."
        
        Name = Application.GetSaveAsFilename(InitialFileName:=Worksheets("HR Use Only").Range("B7").Value & "_" & Worksheets("Hr Use Only").Range("B4").Value & "_" & Worksheets("ConditionalFormat").Range("E18").Value & "_PAF Draft_" & Format(Worksheets("HR Use Only").Range("D5").Value, "mm-dd-yyyy"))
[COLOR=#0000ff]        ThisWorkbook.SaveCopyAs Filename:=Name[/COLOR]
        
        MsgBox "Once you close this message, an email will be created in Outlook. Please attach the file you just saved to this email and press send."
        
        ThisWorkbook.FollowHyperlink (Worksheets("MacLink").Range("B8"))
    
        MsgBox "The email has been created. If you do not see the email, please check your Outlook application in your dock."


    [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=Else]#Else[/URL] 
            'removed to be concise

If they don't actually save the file, I want it to exit the sub. Is there a way to set a variable to test based on whether or not they save?

Thanks!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
If the return value of Name is FALSE, this means Cancel is pressed.
The Name variable (bad choice of name) should be declared as Variant.
 
Upvote 0
Thanks bobsan42! I had my variable defined, I just thought the Name would only return false if it couldn't find the references listed. Good to know!
 
Upvote 0

Forum statistics

Threads
1,216,236
Messages
6,129,652
Members
449,526
Latest member
hmoh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top