要处理的Excel版本是2003的,这个跟电脑上现有的office版本没有关系
asd=getFieldV("[通话时长(s)],","C:\ZCTT\20101122171413.xls")
MsgBox asd
Function getFieldV(fieldsName,xlsPath)
Set xlsDoc = CreateObject("Excel.Application")
xlsDoc.Workbooks.Open(xlsPath)
xlsDoc.Worksheets(1).Activate
Set oSheet = xlsDoc.ActiveSheet
oSheetNam = oSheet.name
xlsDoc.Quit
Set xlsDoc = Nothing
filterV = ""
While InStr(fieldsName,",")<>0
flagnum =0
locNum = InStr(fieldsName,",")
fieldName = Left(fieldsName,locNum-1)
fieldsName =Mid(fieldsName,locNum+1,Len(fieldsName))
MsgBox fieldName
ai = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&xlsPath&";Extended Properties=Excel 4.0"
bi = "Select "&fieldName &" from ["&oSheetNam&"$] group by "&fieldName
Set conn = CreateObject("ADODB.Connection")
conn.Open ai
Set rs = CreateObject("ADODB.Recordset")
rs.Open bi,conn
While Not rs.EOF 'And flagnum < getall_num
rd = rs("通话时长(s)")
MsgBox rd
If StrComp(rd,"")<>0 Then
filterV = filterV &rd&","
flagnum = flagnum + 1
End If
rs.MoveNext
wend
conn.Close
Set rs =Nothing
Wend
If strcomp(filterV,"")=0 Then
getFieldV =""
else
getFieldV = Left(filterV,Len(filterV)-1)
End If
End Function