Display a message when a file is opened.

S

Sheila

I would like to display a message "Complete section two before entering
section one" when an excel file is opened.
Any help would be appreciated.
 
P

Peter Jausovec

Hi Sheila,

You need to create a new macro (ALT+F11) and add a Workbook_Opened event (on
the left side click on ThisWorkbook; a new window will open and in left
dropdown select Workbook and Workbook_Opened will be added). Next, you just
add this line (between Private Sub Workbook_Opened() and End Sub):

MsgBox "Complete section two before entering section one"

Message box will be displayed when document is opened.
--
Best regards,
Peter Jaušovec
http://blog.jausovec.net
http://office.jausovec.net


"Sheila" je napisal:
 
S

Sheila

Thanks Peter this is exactly what I was looking for. Is it possible to change
the size and color of this message?
 
P

Peter Jausovec

No, unfortunately you can't change the size and color with MsgBox. But you
can create your custom form and adjust the whole appearance as you like it.

Click ALT+F11 again, right click on the ThisWorkbook (on the right side) and
select Insert -> User form. A new, blank form will show up; then just add the
label to it, adjust the font size and color. Also add a button so the user
can close the form (drag&drop the button to the form, double click on it and
add this line of code:

Unload Me

(this will unload and close the form when you click on the button).

Finally, go to the Workbook_Opened event and add this line:

UserForm1.Show

(UserForm1 is the name of the form you created - you can change it in the
properties - click on the UserForm1 and in the Properties window find the
(Name) property).

Hope this helps.
--
Best regards,
Peter Jaušovec
http://blog.jausovec.net
http://office.jausovec.net


"Sheila" je napisal:
 
S

Sheila

Thanks for all of your help Peter.

Peter Jausovec said:
No, unfortunately you can't change the size and color with MsgBox. But you
can create your custom form and adjust the whole appearance as you like it.

Click ALT+F11 again, right click on the ThisWorkbook (on the right side) and
select Insert -> User form. A new, blank form will show up; then just add the
label to it, adjust the font size and color. Also add a button so the user
can close the form (drag&drop the button to the form, double click on it and
add this line of code:

Unload Me

(this will unload and close the form when you click on the button).

Finally, go to the Workbook_Opened event and add this line:

UserForm1.Show

(UserForm1 is the name of the form you created - you can change it in the
properties - click on the UserForm1 and in the Properties window find the
(Name) property).

Hope this helps.
--
Best regards,
Peter Jaušovec
http://blog.jausovec.net
http://office.jausovec.net


"Sheila" je napisal:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top