+ Reply to Thread
Results 1 to 7 of 7

open another workbook - close - see again original form

  1. #1
    Registered User
    Join Date
    11-18-2012
    Location
    Kortrijk, Belgium
    MS-Off Ver
    Excel 2010
    Posts
    4

    open another workbook - close - see again original form

    Hi all,

    A question please.

    I have a master workbook. On a form is a commandbutton that opens a second file.
    When the second workbook opens, my form disappears (automatically), the form from the second file appears.
    I have placed this event in workbook.open.

    When I close the second file, I see again the first workbook, but with no form.
    I need the orginally form to be shown.

    Can someone help please?



    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: open another workbook - close - see again original form

    Hi, MJR,

    maybe you can use the Private Sub Workbook_Activate-event in ThisWorkbook for that like
    Please Login or Register  to view this content.
    As that event would alos fire when you just have switched to another workbook you may consider using a boolean variable to decide whether to show the form or loop through the forms to see if itīs open.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    11-18-2012
    Location
    Kortrijk, Belgium
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: open another workbook - close - see again original form

    Hi Holger,

    Thank you for your respons!
    I placed your line in the workbook activate event.
    No result.

    After closing the second file there is no form appearing from the first.

    Any other solution?
    Mario

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: open another workbook - close - see again original form

    Hi, Mario,

    you placed the code in the workbook where the userform is located? The sample code works fine for me - please see a workbook attached (UserForm Button will create a new workbook, if you close that the form will be brought back up again).

    Ciao,
    Holger
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-18-2012
    Location
    Kortrijk, Belgium
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: open another workbook - close - see again original form

    Hi Holger,

    Indeed your file works very fine.
    Thank you for all your attention and work!

    I stille have the problem in my case.
    I have added two files (simplefied).

    What am I doing wrong?

    Thanks in advance.
    Mario
    Attached Files Attached Files

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: open another workbook - close - see again original form

    Hi, Mario,

    I didnīt expect that the other workbook had a form as well and should be closed via that form. In that case the event which is triggered if a workbook is closed "as usual/normal" doesnīt get fired. A workaround for that is to call the macro to show the first form again before the workbook is closed:

    Please Login or Register  to view this content.
    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    11-18-2012
    Location
    Kortrijk, Belgium
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: open another workbook - close - see again original form

    Hi Holger,

    Thank you for your patience and efforts!
    And for your solution!
    This works fine. I can surely work with this.


    Thanks again.

    Ciao,
    Mario,

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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