Hi . I'm trying to use vba to open a .csv file out of excel, and use split to load up the various elements into an array. The elements can be text, numbers and dates. I've read on the net that i can declare my array as an object, and then convert when i want to do something with them. My problem is that I get a type mismatch error on the 'split' line. I've checked the help, msdn help and various web pages, but can't see what i'm doing wrong. Any help would be gratefully received. I'm using Access 2007. The essence of the code is:
Code:
Dim intOutFileCount As Integer
Dim intInFileNo As Integer, intOutFileNo As Integer
Dim strInfile As String, strInRec As String
Dim InRecord() As Object
' open infile
intInFileNo = FreeFile
Open "filename.csv" For Input As #intInFileNo
' loop thru infile
Do While Not EOF(intInFileNo)
' load up InRecord
strInRec = Input(LOF(intInFileNo), intInFileNo)
InRecord = Split(strInRec, ",", -1) ' type mismatch. Error 13
.
. {more code}
.
' write to outfile
Print #intOutFileNo, CInt(InRecord(7)); CDate(InRecord(8)); CDate(InRecord(9))
Loop