How to get Spreadsheet to hide and VBA form to load on application load

Hi Experts,

I need help with an Excel document that I am working on. What I need to do is upon the Excel document loading, hide Excel and display a VBA form. I am relatively new to VBA, so it could be something I am doing wrong or missing.

I have tried the following and similar methods in the actual sheet object, but to no avail...

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.Visible = False
End Sub

Any help would be greatly appreciated.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

EDDYKTConnect With a Mentor Commented:
have you tried to do it in

Private Sub Workbook_Open()
ringroselawAuthor Commented:
This works, but for some reason none of the data in the spreadsheet (sheet1) is shown within the corresponding text boxes on the form.

Do I  need to apply a similar method to the sheet, as opposed to the Workbook?
if you want to set something to userform1


Load UserForm1
UserForm1.TextBox1.Text = Sheets("sheet1").Range("A1").Value
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

ringroselawAuthor Commented:
The form has been setup as above, so on the form loading the text boxes refer to the cells for their values.

I think the problem lies with the way the data is merged into Excel.
Because the data is merged in after the Workbook is opened, the form isn't displaying the data because this hasn't been inputted into cells yet (hope that makes sense).

So what needs to happen is...
- Document Opens
- Data is merged into sheet cells
- Application hides
- Form shows

Wayne Taylor (webtubbs)Connect With a Mentor AstronautCommented:
Hi ringroselaw,

Try putting DoEvents after showing your form.


ringroselawAuthor Commented:
Thanks for your help guys.
All Courses

From novice to tech pro — start learning today.