Creating a Pop up

mrbeanyuk

Board Regular
Joined
Nov 30, 2005
Messages
212
I have used the following coding to create a msg box:

Private Sub Workbook_Onload()
Dim result As VbMsgBoxResult
result = MsgBox("Do not Amend", vbOKOnly, "Warning")
End Sub




Why does this not work when I open the document!

Thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

BBHRVS

Board Regular
Joined
Nov 3, 2005
Messages
94
Hi Mr Bean,

I do not know the onload event...

Private Sub Workbook_Open()
Msgbox "Do not amend", , "Warning"
End Sub

Should be ok. Of course located into the Workbook.module...
 

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Do not understand much of your code.

If you use Project Explorer in VB Editor and doubleclick on ThisWorkbook you get the proper code module for this task. Have a look at the dropdowns at the top for the various event trapping possibilities.

Copy/paste this code there :-
Code:
Private Sub Workbook_Open()
    Dim Result As String ' not really needed here as it is not used elsewhere
    Result = MsgBox("Do not Amend", vbOKOnly, "Warning")
End Sub
 

mrbeanyuk

Board Regular
Joined
Nov 30, 2005
Messages
212
This is still not working for some bizarre reason. The coding is correct but will not open when I open the document.

I hope I am correct in saying that the coding should be put in the Module One bit or the 1st Sheet to make it work!?
 

BBHRVS

Board Regular
Joined
Nov 3, 2005
Messages
94
No, the code should be into the workbook module.
Please go to VBA (by clicking the menu tool/macros/visual basic editor) in Excel.
Then click on menu : view/project explorer
Then open the project of your workbook and double click on "Thisworkbook"
You are in the workbook module. Paste the code we provided.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,805
Messages
5,833,764
Members
430,230
Latest member
Yimmie

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
Top