Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pop-up when opening an existing Excel worksheet

Status
Not open for further replies.

tebbisch

Instructor
May 31, 2004
9
0
0
MY
Greetings from Germany.

I would like to create a pop up message when opening an Excel worksheet. I guess I would have to use the MessageBox1 VBA command.

Any ideas would be greatly appreciated. Thanking you in advance.
 
tebbisch,
You can display a message when a particular workbook opens by putting a MsgBox statement in the Workbook_Open sub. The following code goes in the ThisWorkbook code pane
Code:
Sub Workbook_Open()
MsgBox "This is your friendly pop-up message when the workbook is opened"
End Sub
To paste the sub in the code pane for ThisWorkbook, ALT + F11 to open the VBA Editor then CTRL + R to open the Project Explorer. In the Project Explorer window, doubleclick ThisWorkbook to open its code pane. Paste the code there, then ALT + F11 to return to the spreadsheet.

If you want a message to display when any workbook is opened, then you will need to use a class module. That's somewhat more complicated.
Brad
 
This will allow you to take action depending upon the response.

Sub Auto_Open()
Dim Msg, Style, Title, Response
Msg = "Do you want to continue ?"
Style = vbOK + vbDefaultButton2
Title = "Worksheet Directions"
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then
Else
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
End Sub


Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top