Example 1: VBScript to read the data from an Excel sheet using ADODB object (Active Data Objects Data Base)
kw.vbs
OptionExplicitDimobjCon,objRecordSetSetobjCon=CreateObject("ADODB.Connection")SetobjRecordSet=CreateObject("ADODB.Recordset")objCon.Open"DRIVER={Microsoft Excel Driver (*.xls)};DBQ=D:\VBScript\Trial.xls;Readonly=True"objRecordSet.Open"SELECT * FROM [Sheet1$]",objConMsgboxobjRecordSet.GetStringSetobjRecordSet=NothingSetobjCon=Nothing
Output
Example 2: VBScript to read the data from an Excel sheet using ADODB object
kw.vbs
DimobjCon,objRecordSet,strExlFileSetobjCon=CreateObject("ADODB.Connection")SetobjRecordSet=CreateObject("ADODB.Recordset")strExlFile="D:\VBScript\Trial.xls"objCon.Open"DRIVER={Microsoft Excel Driver (*.xls)};DBQ="&strExlFile&";Readonly=True"Setresult=objCon.Execute("Select * from [Sheet1$]")colCount=result.Fields.CountMsgBox"Number of column: "&colCount&vbcrlf&result.GetStringSetobjRecordSet=NothingobjCon.CloseSetobjCon=Nothing
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.