[VBA HELP] Save file prompt to overwrite, save as or cancel

sasils

New Member
Joined
Jun 3, 2017
Messages
24
Hello,

I need help on VBA for the following requirement.

Pop up message with 3 button of choices
1. Overwrite file
2. Save as different file name
3. Cancel operation.

Thank you so much for your help.

Cheers.....

Sasils
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
To customize the text of the buttons in a simple way, it is using a userform:

9e67b7bac10d0a4e5a9174c9b1f46817.jpg



You can also have 3 buttons with a msgbox.

8c110e87d8c72299eddbab3ffd96d350.jpg



But I guess the most important thing you need is the code to execute the 3 options. Which of the 2 options do you want?
 
Upvote 0
To customize the text of the buttons in a simple way, it is using a userform:

9e67b7bac10d0a4e5a9174c9b1f46817.jpg



You can also have 3 buttons with a msgbox.

8c110e87d8c72299eddbab3ffd96d350.jpg



But I guess the most important thing you need is the code to execute the 3 options. Which of the 2 options do you want?



Hello,

First one please thank you.
 
Upvote 0
Do you know how to create a userform?
Do you need the code for each button or do you already have it?
 
Upvote 0
and what do you want to save, a pdf, an excel or what? It would help if you are more specific.
Path, name, sheet, workbook.
 
Upvote 0
and what do you want to save, a pdf, an excel or what? It would help if you are more specific.
Path, name, sheet, workbook.

1. Overwrite file button = Save the whole excel file with the same file name and path
2. Save as = Save the whole excel as new excel .xlsm with same path and let user maintain name
3. Cancel = Cancel operation

thanks
 
Upvote 0
Create the userform with 3 buttons and put the following code:

Code:
Private Sub CommandButton1_Click()
  ThisWorkbook.Save
  MsgBox "Saved file"
End Sub


Private Sub CommandButton2_Click()
  Application.DisplayAlerts = False
  With Application.FileDialog(msoFileDialogSaveAs)
    .Title = "Save As"
    .AllowMultiSelect = False
    .InitialFileName = ThisWorkbook.FullName
    .FilterIndex = 2
    If .Show Then
      ActiveWorkbook.SaveAs .SelectedItems(1)
      MsgBox "Saved file"
    End If
  End With
End Sub


Private Sub CommandButton3_Click()
  MsgBox "Cancel operation"
  Unload Me
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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