What I had before is essentially similar to your method. I had the following:
set wksheet1=XLApplication.workbooks.open(excel filename as> string).worksheet("ws1")
set wksheet2=XLApplication.workbooks.open(excel filename as
But at the second line, I got a type mismatch error, which I don't
understand why.
with you method, how can you refer to individual cells in the worksheet, and
especially, if I am using a loop to go over a series of cells?
thanks,
First, You have a typo in your posting in that the .worksheet("ws1")
part must be .worksheetS("ws1") (with an S). Does that indicate
anything to you? Specifically, that the property is a COLLECTION of
all of the worksheets in the workbook. So, you could do something
like this ...
set colWksheets=XLApplication.workbooks.open(excel filename as string)
set wks1 = colWksheets("ws1")
set wks2 = colWksheets("ws2")
There are may ways to access cells in a worksheet. A most common way
is to use the Range() property, such as ...
contentWS1A1 = wks1.Range("A1").Value
contentWS2A1 = wks2.Range("A1").Value
Another is the Cells() property ...
contentWS1A1 = wks1.Range(0,0).Value
contentWS1B2 = wks2.Range(1,1).Value
where the parameters are row, col offsets.
Maybe you want to open Excel and record a few macros and then look at
the code that the program creates for the macro to get an idea of
Excel's object model. You can also look at the Excel VBA help
documentation.
Tom Lavedas
===========