Pop-up message box when saving

Tim in Toronto

New Member
Joined
Nov 18, 2004
Messages
47
Hi All,

I'd like to create a message box that pops up when I go to save file. The message box is just a reminder to make sure that certain things were filled out before the file is saved. Any ideas?

Tim :)
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try this: right click the Excel logo just to the left of File on the menu bar, select View Code and paste in

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "Your message here", vbInformation, "Check"
End Sub
 
Upvote 0
Hi Peter,

I don't have an Excel logo to the left of my file menu. However, I think your idea would prompt that message anytime I save a file. I guess I wasn't specific enough. I only want the message box to pop-up when I'm saving a particular file.
 
Upvote 0
Open the specific file that you want to have this message appear in, press ALT + F11 to open the Visual Basic Editor. In the "Project - VBA project" window, double click ThisWorkbook then paste the code into the right hand pane.
 
Upvote 0
VOG, I was able to use this code to produce the popup message I want at the time the user saves. The problem is when I close the workbook and come back in the message no longer appears and the code is gone from VBA. Any suggestions - Karen
 
Upvote 0
Thanks that worked. Two other questions...
1. If I have two lines of text in my message box how do I get them to show in the box on seperate lines instead of one string?
2. Is there anyway to have the worksheet always open with Marcos enabled so the user does not have to make this selection?
 
Upvote 0
1. Try

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "Your message here" & vbNewLine & "Line 2", vbInformation, "Check"
End Sub

2. You cannot.
 
Upvote 0
This worked perfectly for me. Thank you so much for this code. Been trying to figure this out for a couple days and then BOOM, it's all right here. Thanks Again VoG. Joe
 
Upvote 0

Forum statistics

Threads
1,225,216
Messages
6,183,632
Members
453,177
Latest member
GregL65

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