MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Open a Userform When a Workbook is Opened


October 13, 2001 - by Bill Jelen

Hello Mr Excel readers!

Since I have shown that it is nearly impossible to keep up with the tips of the week, I am going to try something insanely ambitious - a tip of the day! Unlike the Tips of the Week which come with several screen prints, etc. This quickie tip of the day will answer some reader's question that may be of general interest.

Let's reach into the mailbag to see who our lucky first reader will be....

With apologies to Brigitte (question too complicated) and Marie (I never answer questions which are *obviously* typed verbatim from your school homework assignment), the first lucky reader is Judy who asks:

I would like to know how you link dialog box from VB Editor to the worksheet. So when I open Excel, the dialog box that I've created from VB Editor will show up first thing.

OK Judy, here is the answer:

When a workbook is opened in Excel, the Workbook_Open macro is automatically run. This macro has to be located in the code pane associated with This Workbook in the VBA editor. If your dialog box is called frmCust, then this macro will do the trick:

Private Sub Workbook_Open()
    frmCust.Show
End Sub

OK, that was not too painful. The obvious problem here is that when I fire off an answer in an e-mail and it is wrong, then I only appear foolish to one person. This new medium allows me to appear foolish to many people at once. Sounds like fun!