Getting data from an open Excel file into Access

A

A

Hi,

I need to get data from an open Excel file into Access
using automation. I declare Application, Woorkbood, and
Worksheet objects and an integer variable in which to get
the data like this:

Dim objExcel As Excel.Application
Dim objWorkbook As Excel.Workbook
Dim objWorksheet As Excel.Worksheet
Dim intExcelValue As Integer

I then set the Application object to an existing instance
of Excel like this:

Set objExcel = Excel.Application

At this point I can't figure out or find how to identify
the specific workbook file from which I need to get the
data. I have tried:

With objExcel
Set objWorkbook = objExcel.ActiveWorkbook
Set objWorksheet = objExcel.ActiveWorksheet
End With

but when a check the values of these object they read "Nothing"

Since I want to get to the following:

intExcelValue = objWorksheet.Cells(3, 8).Value

I need a way to let the code know the specific open file
"C:\Data.xls".

This should be simple but I haven't found a way to do it.

Any help or alternatives, much appreciated.

A
Any help
 

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