Open Excel then return focus to Access

wjoc1

Registered User.
Local time
Today, 04:05
Joined
Jul 25, 2002
Messages
117
Hi,

This is probably going to be a quick one for somebody, I had a search through old posts and couldn't find anything.

I have an Access form and using a button on the form I start an instance of excel. I then have:

Code:
oExcel.Visible

However after I open Excel and make it visible I want to return the focus to the form in the database. How do I do this?

Thanks,
Liam
 
In the declarations section of your Code Module, paste this code:
Code:
Declare Function SetForegroundWindow Lib "user32" ( _
    ByVal hwnd As Long) _
    As Long

then change your existing code to read:
Code:
oExcel.Visible
Call SetForegroundWindow(Application.hWndAccessApp)
 

Users who are viewing this thread

Back
Top Bottom