Extracting Excel Formulas into Access

N

Novelty

I'm writing a program in Access that reads an entire Excel spreadshee
and breaks each cell down into data components for storage in
database. From here, there are modules I've written that will read th
tables I've created and then recreate the Excel spreadsheet in Excel.
(The reason for all this fun is that, in my line of work, we run a lo
of reports that export themselves to Excel so the user can do whateve
they want with them. It's better than providing a static report i
Access.)

Anyway, the issue I'm having is trying to read the formula from a cel
in Excel. Programmatically, it looks like this (pseudo-coded):

DBField = xlSht.Range(CellContent).Formula

The problem is that, even if it's a formula, it returns the text of th
cell instead of the formula. For example, if A1 = 1000 and B1 = A1*2
then the above code would process cell B1 as 2000 instead of th
formula that generated the content.

The helpfiles say that I'm doing it correctly (even going as far as t
point out that it will return the "=" from the formula). However, th
help file and reality appear to be two different things.

Anyone have a good take on what's going on? And, even better, how do
get the formula and not the result?

Thanks,

~No
 
A

AA2e72E

I get the formula string in Excel 2000 using a syntax such as:

activeworkbook.Sheets(1).cells(1,2).Formula

If the target cell contains a value, the code returns the value of the cell.
Whether the cell has a formula can be determined by:

activeworkbook.Sheets(1).cells(1,2).HasFormula

This returns TRUE or FALSE.
 

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