Launching issue of Excel from Access

H

Harry-Wishes

I want to launch Excel from Access which I though would be a piece of cake.
Excel does launch but, when Access reaches the end of the function, Excel
closes. How do I prevent this from occurring?

Public Function cmdTables_Click()
Dim oApp As Object
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
'Some code below

End Function
 
J

Jack Leach

If you just want to open the file without needing to programmaticaly work
inside exel from access, try one of the three:

Application.FollowHyperlink "C:\myfolder\myfile.xls"

or

Shell "C:\myfolder\myfile.xls"

or (my preffered method), use the ShellExecute API:

http://www.mvps.org/access/api/api0018.htm



hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
K

kc-mass

Try this and make sure you have a reference to Excel (In any module
Tools\References)

Dim xlApp As Object
Dim wbExcel As Object
Dim ws As Worksheet
Set xlApp = CreateObject("Excel.Application")
Set wbExcel = xlApp.Workbooks.Add
xlApp.Visible = True
'Some code below
 
H

Harry-Wishes

Thanks to you both.

In my case, I just want to close Access although together once I'm through
with it and work in Excel. I went with KC_Mass's option for this particular
scenario. Things now execute as expected.

Harry Wishes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top