Excel Launch

D

dave h

Hi,

I have linked an Excel file to my application and it works well with DAO
recordset coding. However, I'd like the user to be able to click a button
on a form and bring up Excel. And, I'd like Excel to automatically display
a specific .xls file. This code solves part of the problem:

Dim retval
retval = Shell("C:\Program Files\Microsoft Office\OFFICE11\excel.exe",
1)

However, I have to put the worksheet (.xls file) in C:\Program
Files\Microsoft Office\OFFICE11\XLSTART. This is not the best solution for
multiple files and ease of deployment (I'd like it in the same directory as
the db).

So, is there a way to supply some kind of paramater to excel.exe to cause it
to open the .xls file of my choice (and in my db directory) ?

Thanks, Dave H.
 
A

Alex White MCDBA MCSE

Hi

This is an early bound automated opening of Excel. You will need to set your
references to point to the current version of word.

Dim objXcel As New Excel.Application
objXcel.Quit ' keep having problems without this
objXcel.Workbooks.Open "c:\yourexcel.xls"

This is a late bound automated opening of Excel

Dim objXcel as object
Dim objWorkBook as object
set objXcel = CreateObject("Excel.Application")
Set objWorkBook = objXcel.Workbooks.Open("C:\yourexcel.xls")


both untested but should work.


Hi,

I have linked an Excel file to my application and it works well with DAO
 
D

dave h

Hi,

Thanks for the response. Both versions compile and execute without error
after I added a reference to Microsoft Excel 11.0 object library - I'm using
Access 2003. However, I must be missing something because neither version
does anything. I put the code behing a couple of buttons and they run with
error, but Excel does not come up. Do I need to do something with objXcel
to have it actually launch Excel?

Thanks, Dave H
 
A

Alex White MCDBA MCSE

Hi Dave,

after the other statements


objWorkBook.Activate
objXcel.Visible = True

it is actually running you just could not see it because it was not visible.

should work now..
 

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