Article ID: 194124
Article Last Modified on 6/24/2004
Set Db = OpenDatabase("C:\Temp\Book1.xls", _
False, True, "Excel 8.0; HDR=NO; IMEX=1;")
NOTE: Setting IMEX=1 tells the driver to use Import mode. In this state,
the registry setting ImportMixedTypes=Text will be noticed. This forces
mixed data to be converted to text. For this to work reliably, you may
also have to modify the registry setting, TypeGuessRows=8. The ISAM
driver by default looks at the first eight rows and from that sampling
determines the datatype. If this eight row sampling is all numeric, then
setting IMEX=1 will not convert the default datatype to Text; it will
remain numeric.
0 is Export mode
1 is Import mode
2 is Linked mode (full update capabilities)
The registry key where the settings described above are located is:
Dim Db As Database
Dim Rs As Recordset
Private Sub Command1_Click()
Set Rs = Db.OpenRecordset("Sheet1$")
'This will print the spreadsheet Text values as Nulls.
Do While Not Rs.EOF
Debug.Print Rs(0)
Rs.MoveNext
Loop
End Sub
Private Sub Form_Load()
'HDR refers to the Excel header row.
Set Db = OpenDatabase("C:\Temp\Book1.xls", _
False, True, "Excel 8.0; HDR=NO;")
End Sub
Private Sub Form_Unload(Cancel As Integer)
Db.Close
Set Db = Nothing
End Sub
Run the Project by pressing the F5 key and note that in the Debug window
the text values are printed as Null. If the majority of the values in
the Excel Spreadsheet were text, then the result from the code above
would be reversed. That is, the numeric values would come back as Nulls.
Additional query words: kbDSupport kbdse spreadsheet workbook kbDAO350 kbDAO300 kbDAO250 kbIISAM kbExceL kbVBp400 kbVBp500 kbVBp600 kbVBp kbRegistry
Keywords: kbprb KB194124