Cancelling on Save As dialogue Box

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Code:
ActiveWorkbook.SaveAs Filename:=FileSaveAs, Password:="", writerespassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
I just observed some issue with this code is am trying to use to save my workbook with the Save As dialogue. When I click cancel it goes on to create a file named "FALSE". what is the issue here?
Regards
Kelly
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Kelly,

Can you post a little more code before and after the event to see what is generating the error? When the user clicks 'Cancel' on a FileDialog, it produces the filename of 'FALSE'. You have to trap that condition to prevent the code from proceeding if the user clicked Cancel. Here's some code that I have that does a similar thing. Maybe this will help you, but again, if you could post a little more of your code, that would be great!

Code:
' Pick the output folder
With Application.FileDialog(msoFileDialogFolderPicker)
    .AllowMultiSelect = False
    .Title = "Please select a folder that the output files are to go to..."
    If .Show <> -1 Then
        ' The user cancelled.  Exit the code.
        Exit Sub
    Else
        strOutputPath = .SelectedItems(1) & "\"
    End If ' .Show...
End With

Brian

Brian J. Torreano
 
Last edited:
Upvote 0
Code:
Sub CreateSaveAs ()
FileSaveAs = Application.GetSaveAsFilename(FileFilter:="Exel Files (*.XLSM, *.XLSM", Title:="Select Name To Save The File")
ActiveWorkbook.SaveAs Filename:=FileSaveAs, Password:="", writerespassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
End  Sub
 
Last edited:
Upvote 0
Try this.
Code:
Sub CreateSaveAs()
Dim FileSaveAs As String

    FileSaveAs = Application.GetSaveAsFilename(FileFilter:="Excel Files (*.XLSM, *.XLSM", Title:="Select Name To Save The File")
    
    If FileSaveAs <> "False" Then
        ActiveWorkbook.SaveAs Filename:=FileSaveAs, Password:="", writerespassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
    End If
    
End Sub
 
Upvote 0
Norie,
Workdone . Thanks very much. I am progressing gradually
Kelly
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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