+ Reply to Thread
Results 1 to 11 of 11

Workbook doesn't open (Lost Focus)

  1. #1
    Registered User
    Join Date
    08-23-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    18

    Angry Workbook doesn't open (Lost Focus)

    Hello guys

    I noticed something very strange. When you have an installed AddIn that does nothing more than showing a userform on opening, then the following happens when you start Excel by double clicking on any excel file:

    1) Double Click on any Excel file
    2) Excel Application will start and load the AddIn
    3) The AddIn will show the Userform
    4) I cancel the userform by clocking on the ok button => Unload Me
    5) The original excel file that you double clicked will NOT open anymore

    Can anybody tell me why this happens and how I can prevent it - of course I need the userform during opening and I don't want to use a timer controled start of the userform...

    Regards
    Marc

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Workbook doesn't open (Lost Focus)

    Why do you need a userform when the add-in opens?
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    08-23-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Workbook doesn't open (Lost Focus)

    Quote Originally Posted by romperstomper View Post
    Why do you need a userform when the add-in opens?
    I need it for the trial release of my AddIn MTools. The AddIn is timely unlimited usable, but at least I need such a "buy reminder"...

    However, whatever the reason is, are you not also curious what the reason could be for this problem?

    I also noticed a maybe related issue:
    When you open a userform in the active workbook and the user clicks on a button that starts a "FollowHyperlink" that opens an explorer window on top, then after you close the userform, Excel cannot activate anymore the activeworkbook (lost focus and cannot activate it anymore).
    1) The Focus to the acticeworkbook is lost
    2) Even if you save the old "activeworkbook" : Set wkbBackup = ActiveWorkbook
    the trial to activate the backuped workbook later "wkbBackup.Activate" will fail (No error
    message but it will not change the Active Workbook)


    I really start hyving enough finding workarounds for Excel Bugs...

    Maybe somebody noticed one of these 2 problems also and can help me. I googled a lot but found no infoirmation about those 2 problems.

    Regards
    Marc

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Workbook doesn't open (Lost Focus)

    I can't say I'm particularly curious - I suspect it's a DDE timeout - but the workarounds are quite simple. However, I loathe nag screens so it's one of the few things I won't assist with (like flashing cells).
    I can't replicate your other issue - can you provide sample code to show the exact sequence of events?

  5. #5
    Registered User
    Join Date
    08-23-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Workbook doesn't open (Lost Focus)

    Quote Originally Posted by romperstomper View Post
    I can't say I'm particularly curious - I suspect it's a DDE timeout - but the workarounds are quite simple. However, I loathe nag screens so it's one of the few things I won't assist with (like flashing cells).
    I can't replicate your other issue - can you provide sample code to show the exact sequence of events?
    I have a solution, I just look for the reason. My solution is to use a modeless and/or timer controled form.

    Other issue

    Please install the attached AddIn and look that you have any workbook in the background when you start the Macro in the AddIn.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by romperstomper; 11-24-2010 at 10:04 AM. Reason: code tags

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Workbook doesn't open (Lost Focus)

    Try using Activeworkbook.Followhyperlink instead.

  7. #7
    Registered User
    Join Date
    08-23-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Workbook doesn't open (Lost Focus)

    Quote Originally Posted by romperstomper View Post
    Try using Activeworkbook.Followhyperlink instead.
    That works thanks, but i'm more interested in the reason for the problem than in the solution. By using thisworkbook.followhyperlink I lose the focus and although I saved the old workbook variable, I cannot reactivate that workbook after closing the form.

    oldworkbook.Activate fails but does not produce any error...

    Regards

    Marc

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Workbook doesn't open (Lost Focus)

    It would appear to be a bug since an add-in should not ever be the active workbook.

  9. #9
    Registered User
    Join Date
    08-23-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Workbook doesn't open (Lost Focus)

    Quote Originally Posted by romperstomper View Post
    It would appear to be a bug since an add-in should not ever be the active workbook.
    Yes, maybe. It would not be the first bug that they have and never fix... At least they collect all their bugs in a nice bug list...

    However, there is a solution that I found although it still doesn't explain the problem:

    If you use first the Workbooks collection to activate any other workbook, then the problem is fixed...
    Please Login or Register  to view this content.
    Thanks and Regards
    Marc
    Last edited by romperstomper; 11-24-2010 at 10:21 AM. Reason: tags again

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Workbook doesn't open (Lost Focus)

    I thought you weren't interested in solutions?

    In future, when posting code (however little) please use code tags as per the forum rules. I have added them for you twice now.

    Also, don't forget to mark this solved, please.

  11. #11
    Registered User
    Join Date
    08-23-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Workbook doesn't open (Lost Focus)

    Quote Originally Posted by romperstomper View Post
    I thought you weren't interested in solutions?

    In future, when posting code (however little) please use code tags as per the forum rules. I have added them for you twice now.

    Also, don't forget to mark this solved, please.

    I'm sorry. I must admit I didn't read all the rules... It's a lot of text you know...
    I didn't notice, that you fixed my postings. Of course I will use the code tags in future...

    I'm interested in fixing the problem and your way is better than mine, although I always prefer also to understand why something doesn't work, but I can live with the fact that it is - as often - one of many many Excel bugs...

    Regards
    Marc

    [SOLVED]
    Last edited by Marc2010; 11-24-2010 at 01:54 PM.

+ 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