Pop up box

RichieF

New Member
Joined
Apr 17, 2002
Messages
20
Upon opening an Excel file, I want a pop-up box to appear on screen which contains some text, and which has yes and no option buttons within it. If the person opening the file clicks yes, the excel file opens, and if they click no, it doesn't (ie something similar to a user agreement to certain conditions prior to using the file)

Any ideas what code I need to use to do this ?

Thanks.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
Sub AUTO_OPEN()

TEST = MsgBox("Do You Want to Open This File?",vbyesno,"OPEN?")

IF TEST = VBNO then Exit Sub

End Sub
 

Russell Hauf

MrExcel MVP
Joined
Feb 10, 2002
Messages
1,611
You can put a message box in the Open event of the workbook module. Something like this:

Code:
Private Sub Workbook_Open()

    If vbNo = MsgBox("Do you agree that you are responsible if this " & _
                      "workbook corrupts your computer and erases your " & _
                      "hard drive?", vbQuestion + vbYesNo, _
                      "Your word is your bond") Then
        ThisWorkbook.Close False
    End If
                      
End Sub

This needs to go in the Workbook Module. For information on how to access the workbook/worksheet modules, click HERE.

Let me know if you can't get it to work.

Hope this helps,

Russell
This message was edited by Russell Hauf on 2002-11-07 14:17
 

Forum statistics

Threads
1,144,273
Messages
5,723,437
Members
422,497
Latest member
dougy99

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