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
FRM_CrimeTravel.Show
End Sub

Any help would be greatly appreciated.
ringroselawAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

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

Private Sub Workbook_Open()
0
 
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?
0
 
EDDYKTCommented:
if you want to set something to userform1

then

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

With monday.com’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



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

Try putting DoEvents after showing your form.

Regards,

Wayne
0
 
ringroselawAuthor Commented:
Thanks for your help guys.
0
All Courses

From novice to tech pro — start learning today.