How to Create a Pop Up Message Box Upon Opening Excel File

rommelq

New Member
Joined
Aug 26, 2002
Messages
47
Hi. Can anybody help me on how to create a message box so that anytime the excel file is opened, the message box will pop up and only upon clicking the "OK", it would disappear. The message I want is " This is only a tentative database. "

And also i want the prompt to appear before the excel file closes to remind the user again.

Thanks. :)
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi -

During opening
Code:
Private Sub Workbook_Open()
MsgBox "This is only a tentative database.", vbInformation + vbOKOnly, "Message from Rommel"
End Sub

Before close;
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "This is only a tentative database.", vbInformation + vbOKOnly, "Message from Rommel"
End Sub
 
Upvote 0
Thanks agihcam for your reply. I went to macro and clicked Visual Basic Editor. Then i insert a module and posted the codes. Then i saved it. Unfortunately, it didnt work when i tried to open the file. I enabled the prompt "enable macros" but still nothing. What could be the error?
 
Upvote 0
hhhhmmm. those codes should be at thisworkbook module not on the standard module. double click thisworkbook from VBA project to the left then paste the codes on the large white screen to the right.
 
Upvote 0
Hi, I have another follow up question. What if i want to put a cancel button at the closing message box so that the excel file won't close? What codes should i put?
 
Upvote 0
try;
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("This is only a tentative database.", vbInformation + vbOKCancel, "Message from Rommel") = vbCancel Then
Cancel = True
Else
Cancel = False
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,206,971
Messages
6,075,925
Members
446,170
Latest member
zzzz02

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