+ Reply to Thread
Results 1 to 15 of 15

activating userform without showing workbook

  1. #1
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    activating userform without showing workbook

    Hi,

    i am just wondering if there is any coding to allow userform to run without showing the workbook.my idea is to run the userform when the workbook opens and then close the workbook.
    Please Login or Register  to view this content.
    however, the workbook will close only after i close the userform. so does anyone know how i can change my coding to make it work?i will gladly welcome any advice or opinions

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

    Re: activating userform without showing workbook

    A quick example brought me this solution
    Please Login or Register  to view this content.

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

    Re: activating userform without showing workbook

    You must be extremely careful with this. If an error closes the userform, then you will have an invisible instance of excel

    Please Login or Register  to view this content.
    Last edited by royUK; 09-14-2010 at 07:21 AM.
    Hope that helps.

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

    Free DataBaseForm example

  4. #4
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    Re: activating userform without showing workbook

    sorry for the late reply as i was unavaible to have access to internet until now. where am i supposed to insert the codes above? in "thisworkbook" ? or in the userform itself?

    ps: the userform is supposed to run in the desktop, without showing workbook at all if possible

  5. #5
    Registered User
    Join Date
    09-06-2010
    Location
    Bristol
    MS-Off Ver
    Excel 2003
    Posts
    96

    Re: activating userform without showing workbook

    The following code should work fine:

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    Re: activating userform without showing workbook

    @nancy123: your code works for me, however, it hides all the excel workbooks. is it possible to hide only that workbook while leaving the other workbooks still visible? i tried using
    Please Login or Register  to view this content.
    but it still hides all workbooks.

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

    Re: activating userform without showing workbook

    Why do you want to hide the workbook?

    If the workbook only acts as a container for the code then you should turn it into an add in

  8. #8
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    Re: activating userform without showing workbook

    @roy:my boss wants to key in data into the userform only and does not wish to see the workbook at all. i had already created a button in the userform to show the workbook when necessary. by the way, what do u mean by "If the workbook only acts as a container for the code then you should turn it into an add in"?

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

    Re: activating userform without showing workbook

    If the code is held in the workbook but nothing else, i.e. no data then an add in would be appropriate.

    I can't see why not seeing the workbook is necessary, but the simplest way would be to have a blank sheet visible when inputting with the form.

    With code
    Please Login or Register  to view this content.
    Set the form's ShowModal property to false

  10. #10
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    Re: activating userform without showing workbook

    there will be data in the workbook. technicians and engineers will enter data into the userform and it will be transferred into the workbook while admin gets to open the workbook and look at all the data keyed in by technicians and engineers.my boss wants only the userform to show for visual effect. looks neater

  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: activating userform without showing workbook

    Have you tried the code that I posted?

  12. #12
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    Re: activating userform without showing workbook

    sorry for the late reply. i am unable to get a connection until now. the code doesnt work for me. i tried pasting the code in sheet 1, as well as pasting it in "thisworkbook". but the workbook is still visible.

    Please Login or Register  to view this content.
    both codes above are able to hide my workbook, however, other workbooks are hidden as well. i suspect that the problem lies with "application" code.

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

    Re: activating userform without showing workbook

    The code that I posted is for the Userform, the clue is in
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    Re: activating userform without showing workbook

    hmmm. i tried your coding and it does not work.the workbook does not close. i tried putting the coding in "thisworkbook" as well as "userform".i believe that the "userform_initialize()" does not work for me.

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

    Re: activating userform without showing workbook

    The event works for any excel, the code also works.

    Attach the workbook

+ 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