Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Leaving Excel Active and Open

Status
Not open for further replies.

Hmadyson

Programmer
Mar 14, 2001
202
US
I have created a process to export queries from Access to XL. Now I want to make sure that XL is left open with the newly created workbook on top. I know that this must be a dumb question, but I am used to setting all of my variables = Nothing, and I can't figure out how to lauch the spreadsheet without leaving any open variables.
 
Hi.

I've a routine that does the same thing. I just added Set objExcel = Nothing to the last line of code and ran it. Excel is still open. So, we just released the variable, not the instance of excel. Now, how do we set the focus ?? If you can live with just jumping to it manually.....Otherwise, perhaps you could make an API call to the windows system, determine which window excel resides in and go there. Unfortunately, I'm not at all farmiliar with API calls.

P.S., good practice releasing your variables.

 
Usually you can just use the AppActivate statement to go to Excel. The syntax is as follows:

AppActivate "Microsoft Excel"

If your code is doing very little after releasing the object, you may also be able to make it active just by setting the visible property to true:

objExcel.Visible=true

DatabaseGuy is correct - you can set the variable to nothing without closing Excel, and you should do this whether closing the app or not.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top