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
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,530
Messages
5,572,675
Members
412,481
Latest member
nhantam
Top