Worksheet_open, VBA

Grammarjunkie

Board Regular
Joined
Mar 22, 2016
Messages
86
Is there a worksheet_open or something that I can use to make a popup alert when the document is opened?

For example, you open up the document, and immediately there's a popup that reads, "Welcome!"
 
Is there a worksheet_open or something that I can use to make a popup alert when the document is opened?

For example, you open up the document, and immediately there's a popup that reads, "Welcome!"
Hi Grammarjunkie,

- Press ALT+F11 to open the VBA Developer window
- Find the name of your workbook in the Project Panel in the top left corn er of the VBA window
- Right-Click on ThisWorkbook and select View Code
- In the new window that opens simply copy / paste in the following:

Code:
Private Sub Workbook_Open()
MsgBox "Welcome " & Application.Username & "!"
End Sub

- Remember to save the document as a macro-enabled workbook (.xlsm).
 
Upvote 0
Hi Grammarjunkie,

- Press ALT+F11 to open the VBA Developer window
- Find the name of your workbook in the Project Panel in the top left corn er of the VBA window
- Right-Click on ThisWorkbook and select View Code
- In the new window that opens simply copy / paste in the following:

Code:
Private Sub Workbook_Open()
MsgBox "Welcome " & Application.Username & "!"
End Sub

- Remember to save the document as a macro-enabled workbook (.xlsm).


Thank you, Fishboy! Just so I can learn exactly what I'm seeing, what is the "& Application.Username & "!" part of it for?

Also, is there a way to change the font of the msgbox?
I'm not used to macros and such, so I apologize if these are dumb questions.

Thank you in advance.
 
Upvote 0
Thank you, Fishboy! Just so I can learn exactly what I'm seeing, what is the "& Application.Username & "!" part of it for?

Also, is there a way to change the font of the msgbox?
I'm not used to macros and such, so I apologize if these are dumb questions.

Thank you in advance.
Hello again Grammarjunkie,

Code:
MsgBox "Welcome " & Application.Username & "!"

On my PC the above code would display a message box like this:

V6NGe525.jpeg


Application.Username displays the user name of the currently logged user. Feel free to take that bit out if you prefer.

& "!" is just adding the exclamation point on the end. If you would prefer just the word "Welcome!" the line of code would just read:

Code:
Msgbox "Welcome!"

With regards to changing fonts, a standard message box is not capable of having the font changed (size, style, colour etc). If you were looking for more customization options then you would need to create and design custom userforms in the VBA Developer window and call those instead of a message box. It isn't too complicated to do, but is definitely more work than a standard message box.

You can find out more about custom forms as message boxes HERE (amongst a number of other places no doubt).
 
Last edited:
Upvote 0
Hello again Grammarjunkie,

Code:
MsgBox "Welcome " & Application.Username & "!"

On my PC the above code would display a message box like this:

V6NGe525.jpeg


Application.Username displays the user name of the currently logged user. Feel free to take that bit out if you prefer.

& "!" is just adding the exclamation point on the end. If you would prefer just the word "Welcome!" the line of code would just read:

Code:
Msgbox "Welcome!"

With regards to changing fonts, a standard message box is not capable of having the font changed (size, style, colour etc). If you were looking for more customization options then you would need to create and design custom userforms in the VBA Developer window and call those instead of a message box. It isn't too complicated to do, but is definitely more work than a standard message box.

You can find out more about custom forms as message boxes HERE (amongst a number of other places no doubt).


Oh! Nifty!

Thank you so much for your help. :) I really appreciate it.

I hope you have a great day!
 
Upvote 0

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