Results 1 to 9 of 9

Thread: AppActivate problem in Windows 7

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2011
    Posts
    5

    AppActivate problem in Windows 7

    I am testing an application developed using VB6 on a computer with Windows 7. That application uses AppActivate in order to activate MS Excel so the user can select a cell and then go back to my application. The problem is with Windows 7, because AppActivate keeps Excel flashing in the task bar and the expected behavior was that the Excel main window became the top window with the focus on it. The same code works as expected with Windows XP.

    Does anybody know if there is a workaround for Windows 7?

    Thank you in advance for your help.

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2011
    Posts
    5

    Re: AppActivate problem in Windows 7

    Quote Originally Posted by RhinoBull View Post
    You may need to use SetForegroundWindow api:
    Sample 1
    Sample 2
    Thank you for your suggestions.. but no luck , both approaches work well on XP but neither of them on W7.

    Sample1 - ForceForegroundWindow on W7 simply does nothing

    Sample2 - What I get after executing RestoreWindow is a flashing window in the task bar, exactly the same behavior than AppActivate

  4. #4
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,894

    Re: AppActivate problem in Windows 7

    This one:

    http://vb.mvps.org/samples/ForceFore/

    Works for me on Windows7 Profession 32-bit - it is by the same author in the first link (PDF), but maybe he updated it on his website? I didn't compare the code.

    If it doesn't work for you - what version of Windows 7 are you using?

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2011
    Posts
    5

    Re: AppActivate problem in Windows 7

    Quote Originally Posted by jpbro View Post
    This one:

    http://vb.mvps.org/samples/ForceFore/

    Works for me on Windows7 Profession 32-bit - it is by the same author in the first link (PDF), but maybe he updated it on his website? I didn't compare the code.

    If it doesn't work for you - what version of Windows 7 are you using?
    Yes, that sample application works for me too.

    Then the problem may be my app, because I copied the same code and the result is the flashing window in the task bar.

    This extrange behaviour happens with W7 64-bit.

    I'll review my code for 64-bit.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: AppActivate problem in Windows 7

    Question: Why do you need to select a cell in the first place? Depending upon your needs, you could acess the cell's value using Excel Automation and end up with something like...

    Text.Text = oCell.Value 'etc where oCell is instanciated with code.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2011
    Posts
    5

    Re: AppActivate problem in Windows 7

    Quote Originally Posted by RobDog888 View Post
    Question: Why do you need to select a cell in the first place? Depending upon your needs, you could acess the cell's value using Excel Automation and end up with something like...

    Text.Text = oCell.Value 'etc where oCell is instanciated with code.
    Because first the user selects an element data in my app, then my app activates Excel and the user picks a cell where he wants to copy the data. The "selection changed" event causes the data being copied, and my app is activated again, allowing the user to select another data, and so on.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: AppActivate problem in Windows 7

    Ok then perhaps it might be easier to do it all in VBA so you can use an Excel UserForm? Then there wont be any back and forth focus issues but this depends upon your source app.

    If you are just doing SetForegroundWindow you may need to check first if your window is minimized (IsIconic) first. If it is then restore the window and THEN set it with SetForegroundWindow.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    New Member
    Join Date
    Jun 2011
    Posts
    5

    Re: AppActivate problem in Windows 7

    Thanks for the info RobDog888

    I am trying several approaches, focused in W7 64-bit

    If I find a sucessfull solution I'll tell you in this thread

Posting Permissions

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



Click Here to Expand Forum to Full Width