HOWTO: ExtractInformation From Excel Sheet with DAOID: Q190195
|
The Excel ISAM driver is limited in the sense that it does not dynamically convert datatypes.
If there is a column in your Excel spreadsheet that contains both text and
numbers, the ISAM will not be able to correctly interpret which datatype it
should be. Please make sure that all the cells in a column are formatted to
be the same datatype. For example, you might have following data in four
columns in an Excel sheet:
male female children teens
11 cc 78 ee
22 xx 33 ff
45 uu 56 oo
named range 'myRange1' :
male female children teens
named range 'myRange2' :
11 cc 78 ee
22 xx 33 ff
45 uu 56 oo
excel File : test.xls with the following entries:
male female children teens
11 cc 78 ee
22 xx 33 ff
45 uu 56 oo
named range : myRange1
male female children teens
named range : myRange2
11 cc 78 ee
22 xx 33 ff
45 uu 56 oo
private Sub Command_click1
im dbtmp As DAO.Database
im tblObj As DAO.TableDef
im rs As DAO.Recordset
et dbtmp = OpenDatabase_
("<complete path>\test.xls", False, True, "Excel 8.0;")
DoEvents
Set rs = dbtmp.OpenRecordset("select * from `myRange2`")
While Not rs.EOF
For x = 0 To rs.Fields.Count - 1
Debug.Print rs.Fields(x).Value
Next
rs.MoveNext
Wend
End Sub
Note the reverse apostrophe "`" while specifying the range
name(myrange2).
11
cc
78
ee
22
xx
33
ff
45
uu
56
oo
Please refer to the documentation for how to connect to Excel through DAO. Another good reference will be the upcoming ADO->Excel reference.
Additional query words: kbDAO350 kbIISAM kbDatabase kbDSupport kbdse kbVBp500 kbVBp600
Keywords :
Version :
Platform : WINDOWS winnt
Issue type : kbhowto
Last Reviewed: May 27, 1999