+ Reply to Thread
Results 1 to 16 of 16

Userform to Start When Workbook Opens

  1. #1
    Registered User
    Join Date
    04-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Userform to Start When Workbook Opens

    I have my userform coded to show when the workbook opens, but if another workbook is open, or even just the Excel application and no workbook, then when I open my program's workbook, the userform doesn't show up.....how can I fix this to where it always comes up when I open my program? Thanks

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Userform to Start When Workbook Opens

    You need to attach the workbook. If it;s coded correctly you shouldn't have this problem
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    04-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Userform to Start When Workbook Opens

    how do i attach the workbook?

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Userform to Start When Workbook Opens

    Quote Originally Posted by JP777 View Post
    how do i attach the workbook?
    The same way you did it in your previous posts.

  5. #5
    Registered User
    Join Date
    04-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Userform to Start When Workbook Opens

    i have this in the This Workbook module:
    Please Login or Register  to view this content.
    This gets the userform to show up when I open the program and there is no other excel program running. If anything else with excel is running, the userform doesn't show up when opening my program. Where else do I need to attach it?

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Userform to Start When Workbook Opens

    hi, it should work even if you have another workbook opened. try to test yr UserForm adding a button (i.e in Sheet1)
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Userform to Start When Workbook Opens

    You may have to use the Personal Macro Workbook.
    And use code found here to work with any workbooks being opened.

    Application Events In An Existing Object Module
    Place this code in the personal macro workbook.
    The code using the example from Chip's site will look like this.
    Placed in the workbook module.
    Please Login or Register  to view this content.
    Save and exit from Excel.
    Reopen excel and see what happens when you open workbooks.

    Customize the code for your needs. You can also put UserForms in your Personal Macro Workbook.

  8. #8
    Registered User
    Join Date
    04-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Userform to Start When Workbook Opens

    I tried the code you provided after reading on the link you posted, and I used this as my code:
    Please Login or Register  to view this content.
    but I am still having the issue of the userform not showing up if I try to open the program when Excel is already running....Any other suggestions? Thanks for all the feedback!

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Userform to Start When Workbook Opens

    does your workbook actually open?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Userform to Start When Workbook Opens

    Did you follow my instructions and use the code provided to see how well that works before editing it?
    Is the code in the Workbook module of the Personal Macro Workbook?
    Are you familiar with the Personal Macro Wokbook?

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Userform to Start When Workbook Opens

    You shouldn't need to use any different code. If the code is actually in the correct place & not typed into a module then it will run whenever it is opened with macros enabled. As I said attach the workbook so that we can see the code properly

  12. #12
    Registered User
    Join Date
    04-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Userform to Start When Workbook Opens

    JosephP, the workbook does actually open up with Excel running, just not the userform.

    Dave, I will try the message box deal and see what happens

    royUK, see the attached workbook for code.
    Attached Files Attached Files

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Userform to Start When Workbook Opens

    if you create another workbook with a blank form and set it to run on open, does it work if you already have Excel open?

  14. #14
    Registered User
    Join Date
    04-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Userform to Start When Workbook Opens

    yes, i tried to create another workbook, and it brought up the userform on open even when Excel was already open. I then tried on my program again. When the program is first opened, the userform will show up even if Excel is running. The problem comes after I close the program via the userform. after that, the userform doesn't show up on open with Excel running.

    I apologize for my "moment" earlier in the post. I didn't realize royUK was telling me to attach my program when he told me to attach the workbook. I asked how to do it because I thought he was talking about some special linking process with vba.......

  15. #15
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Userform to Start When Workbook Opens

    one of the last lines of the form close code is
    Please Login or Register  to view this content.
    so it ain't too surprising that events won't run after that. ;-)

    you need to set up a public boolean variable, set it to true in the form close code and then in the workbook_beforeclose event check if the variable is true and if so just exit without putting up your message.

  16. #16
    Registered User
    Join Date
    04-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Userform to Start When Workbook Opens

    that worked, JosephP, thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1