All about Visual Basic for Application (VBA) especially for Microsoft Excel.


  • Subscribe

How to show userform only when we open excel file? While excel file is hidden..

Posted by | January 3, 2012 .

Normally when we double click excel file icon it will automatically open your file but this time we wanted to show User form only where excel file will be call when necessary. In order to do this we can use function below:

ThisWorkbook.Application.Visible = False Or set to True.

What we do is to set the file visible is False when we open excel the file and when click button at userform to show then we set visible is True.

The example as below:

2 things we must do

1) Under This Work Book Module insert below code:

Private Sub Workbook_Open()
    ThisWorkbook.Application.Visible = False
End Sub

2) Now create one user form (of course default will be UserForm1 with button. Double click this button and insert below code:

Private Sub CommandButton1_Click()
    ThisWorkbook.Application.Visible = True
End Sub

You’re done.
Now save this file close. When we open this file we will see userform with button. When we click this button this form disappear and excel file is open.
If you have any question or project please e-mail to me, I will reply and create for free.
Click Here to E-mail


Share Button
Share on Facebook
Bookmark this on Digg
Bookmark this on Yahoo Bookmark
Bookmark this on Google Bookmarks
Bookmark this on Delicious

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)



3 Comments so far
  1. Tariq February 10, 2012 7:56 am

    Hi Hisham..I tried this code but failed.

    I’m using Excel 2010..but the application still opened without showing the form first..please help

  2. hisham hadi February 18, 2012 1:09 am

    For 2010 I think you should save as .xlsm instead .xlsx to enable the macro at opening stage. Thanks

  3. R Taylor July 5, 2012 9:29 pm

    This works fine, but when you do this, you can’t see the application on the toolbar. If you cover it up with other windows you can’t find without closing /moving windows. If you click show desktop, it’s really gone and you can’t get it back without bringing up task manager (and it doesn’t show up in the list of tasks).

    Do you have a solution for this?