View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Eric[_12_] Eric[_12_] is offline
external usenet poster
 
Posts: 7
Default Excel data into VB 6.0

After determining that ADO does not work, since it cannot read an Excel Cell
with just a number in it:
I started down the path you're talking about here. I managed to open the
excel file and could see it in the debug watch, but couldn't figure out how
to read the cells. I tried this code you put in here, and got runtime error
438 "Object does not support this property of method" on the line: vTmp =
xwb.Cells(iRow.iCol)
Is this not the right way to read in cells? Am I missing one of those
Project - References things? I have it referencing:
Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation
Microsoft Data Environment Instance 1.0 (SP4)
Microsoft ActiveX Data Objects 2.5 Library
Microsoft Excel 9.0 Object Library
(removed Microsoft ADO reference which should no longer be needed)

"S. Daum" wrote in message
...
I think Bob meant something like the follwing - done in VB6. The VB6

project
would have to reference Excel - unless you did this with late binding (not
shown).

Sub ReadExcel(sFile as string)

Dim xl as new Excel.Application
Dim xwb as Excel.Workbook
Dim iRow as integer
Dim iCol as integer
Dim vTmp as variant
Dim sLine as string
CONST DELIMITER=","

set xwb xl.workbooks.open(sFile)
for iRow = 1 to 10
for iCol = 1 to 5
vTmp = xwb.cells(iRow,iCol)
sLine = sLine & DELIMITER & vTmp
next iCol
' write sLine to the file here...maybe trim the leading delimiter
sLine = ""
next iRow

end sub

The syntax may not be exact, I'm just showing the idea...

Steve