Creating a Pop up

mrbeanyuk

Board Regular
Joined
Nov 30, 2005
Messages
213
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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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...
 
Upvote 0
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
 
Upvote 0
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!?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,412
Messages
6,119,369
Members
448,888
Latest member
Arle8907

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