• Hi,
    I have created a form in excel.But i want the form to automatically pop-up once the file is opened.Is it possible.

    Regards,
    Salim Thaj

  • Re: Form PopUp


    Just put the code to display the form in the workbook open event.

    Code
    Private Sub Workbook_Open()
        UserForm1.Show
    End Sub


    To access the Open event of a workbook:


    1. Right click the small Excel icon next to File on the main toolbar and select View Code.


    2. Select Workbook from the left dropdown.


    3. You should now see the following code:


    Code
    Private Sub Workbook_Open()
    
    
    End Sub


    This is where you put any code to be run when the workbook opens.

    Boo!:yikes:

  • Re: Form PopUp


    Sure can. You just need an event macro.


    I assume you have a macro that shows the userform.


    You need to trigger the macro that shows your form when you open the file.


    In VBA Editor, double-click on ThisWorkbook. Select Object = Workbook (upper-left dropbox). The VBA editor inserts an event macro. If it's not the Private Sub Workbook_Open macro, delete that macro. Now select Procedure = Open (upper-right dropbox).


    In the Private Sub Workbook_Open macro insert a line:


    Application.Run "your_macro


    That should do it for you.


    Norie beat me to it. You can put the code to show the userform directly in the Private Sub Workbook_Open macro. If you want to display the same userform at other times while the workbook is open, you may want to create a separate macro to show the userform, depending on whether you have other coding that is not included in the userform code.

    Barbara - aka The Cat Lady :cat:


    Please do not U2U (private message) me directly for questions that should be posted to the forum; any such U2Us, unless requested by me, will be deleted.

  • Re: Form PopUp


    Syntax error. Enclose the macro name in double-quotations:


    "Login"

    Barbara - aka The Cat Lady :cat:


    Please do not U2U (private message) me directly for questions that should be posted to the forum; any such U2Us, unless requested by me, will be deleted.

  • Re: Form PopUp


    Salimthaj,


    You have this in your code:

    Code
    Private Sub Workbook_Open()
    Application.Run Login
    
    
    End Sub


    replace with this:

    Code
    Private Sub Workbook_Open()
    Login.show
    
    
    End Sub
  • Re: Form PopUp


    Oops, answered too quickly and jumped on the obvious.


    If you had a macro named Login, then it would be:


    Application.Run "Login"


    However, you tried to combine Norie's method and mine.


    Code
    Private Sub Workbook_Open()
        Login.Show
    End Sub

    Barbara - aka The Cat Lady :cat:


    Please do not U2U (private message) me directly for questions that should be posted to the forum; any such U2Us, unless requested by me, will be deleted.

  • Re: Form PopUp



    That's because you didn't actually use my suggestion. :)

    Boo!:yikes:

  • Re: Form PopUp


    Sorry Norie i didn't understand that at that time.


    Its working fine Now.


    What i did was i didn't use ".


    Thanks for ur help and concern.


    Sorry if i have bothered u too much.


    Thanks a lot once again.

    Regards,
    Salim Thaj

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!