Using Excel from Access

pdbowling

Registered User.
Local time
Today, 00:33
Joined
Feb 14, 2003
Messages
179
Hi, all. This is probably really easy.

I've got a macro that calls Excel from Access. It works fine on my PC, but when I try to run it somewhere else, it keeps crashing (probably a setting I need to change).

Whenever I didn't explicitly declare a variable it would tell me that the 'project or object wasn't found'. Well, I fixed this by declaring everything. No big. BUT....

Dim ExcelApp as application <-- fine
Set ExcelApp = CreateObject("Excel.Application") <--fine
With ExcelApp <-- fine
.workbooks.Open "C:\myFile.xls" <-- CRASHES!!!!!!!
end with

I tried to declare workbooks but there is no type for it.
I'm sure it's just a setting somewhere in Access. I just don't know where it is and how to change it. Any suggestions out there?
PS I did not use Option Explicit in my code.
Thank so much everyone.
PB
 
Check under Tools-References on the machines you use to ensure the same reference libraries are available.
 
Make sure that the excel file is there in c:\.

Why don't you store the excel file in the same folder of the db? Then you can use a relative path like this.

...
.workbooks.Open CurrentProject.Path & "\myFile.xls"
...

The CurrentProject.Path is only available for A2K and higher.
 
Hmm

Hey, thanks for the responses.
Perhaps I am asking the question incorrectly. The code I have Works. There's nothing wrong with it. When I move to a different PC than I wrote the macro on, it crashes. The file Is there and the path is the same. Why should the same version of Access on the same operating system perform differently? It's got to be a setting in Access somewhere. Anybody know where, or anybody know the real scoop on why they might behave differently? Thanks again everyone.
PB
 

Users who are viewing this thread

Back
Top Bottom