Executing Excel in background - why doesn't it work as a module?

M

Morris

Hi everyone,

Only yesterday I made some Excel operations in another database and
everything was working fine, so today I'm trying to do it in another
one and it fails.

I 've got Access 2003, open a 2000 version database. I choose
'Modules' from the left hand side, create a new module, put this code
in:


public sub subCreate()
Dim objXLApp As Object
Dim objXLWb As Object
Dim objSheet As Object

Set objXLApp = CreateObject("Excel.Application")
Set objXLWb = objXLApp.Application.Workbooks.Open("c:\temp\gps.xls")
Set objSheet = objXLWb.Worksheets(1)

(...)

end sub

And it stops on line: Set objXLWb =
objXLApp.Application.Workbooks.Open("c:\temp\gps.xls")
with an error: Runtime error 1004, Unable to get the 'Open' property
of the Workbooks class

the only difference to my yesterday's database is that this is being
run in a Module, not in Microsoft Office Access Class Objects, but can
I make it somehow work?

Cheers,
Morris
 
R

Ruel Cespedes via AccessMonster.com

Check your References and make sure you have Microsoft Excel 11.0 Object
Library checked off.
 

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