Reference Excel Cell Value from Access/VBA

A

AccessARS

Hello, I'm trying to retrieve a value from a particular sheet and cell in an
existing spreadhsheet which has 3 worksheets. My current code is as
follows...

Dim objXL As Object
Dim strWhat As String
Dim strXls As String
Dim objActiveWkb As Object

strXls = "A:\Dashboard\dbUploads\db_Actions.xls"


objXL.Application.Workbooks.Open (strXls)
Set objActiveWkb = objXL.Application.ActiveWorkbook

With objActiveWkb
strWhat = .Worksheets(1).Cells(1, 1).Value

End With

objXL.Application.Quit

Set objActiveWkb = Nothing: Set objXL = Nothing
msgbox strWhat


....it seems to be running fine with no errors but unforunately the value
that I get for that range which I'm assuming ".worksheets(1)" is looking at
the 1st sheet and thereafter row 1 and column 1, does not correspond with any
of the 3 sheets row 1 col 1 values??? Its actually a number that I can't
seem to tie to any cell in my spreadsheet at this point.

Your assistance would be greatly appreciated....Thank you
 
J

Jeanette Cunningham

Answered in the other group which you posted this question to.

Jeanette Cunningham
 
A

AccessARS

....you are definitly on the right track...The cell in question is in an a SAP
genertated Excel template. Although it allows you to save and close in an
excel file for later use, for some reason it won't allow me to view the
content from that sheet even if I link the cell into a second new sheet
within the same workbook. I will have to find a way around it...Thank you.



:



Jeanette Cunningham 3/27/2008 2:41 PM PST



Hi,
It could be something about the particular workbook you are getting the
values from.

Create a new test workbook, put values in the first cell and try the code to
retrieve the values.
If it works OK, then what is the problem with db_Actions.xls?
If it doesn't work, debug on the new text workbook until you get it working.

Jeanette Cunningham
 

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