0

I am trying to fetch values from Excel using below code in .VBS:

strScenarioSheet = "D:\User.xlsx"
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
    strScenarioSheet & ";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"""
strSQL_TC = "Select * from [TestCases$] where [Flag]='Y'"
Set objTot = getRecords(strConnection,strSQL_TC)
MsgBox objTot.RecordCount

Function getRecords(strConnection,strSQL_TC)
    Set objConn = CreateObject("ADODB.Connection")
    objConn.Open strConnection
    Set objRec = CreateObject("ADODB.Recordset")
    objRec.CursorLocation = 3
    objRec.Open strSQL_TC,strConnection
    objRec.ActiveConnection = Nothing
    Set getRecords=objRec.Clone
    objConn.Close
    Set objConn = Nothing
    objRec.Close
    Set objRec = Nothing
End Function

I get this below error:

enter image description here

Why do I get this provider not installed even though I have it in (C:\Windows\SysWOW64):

enter image description here

I tried using this thread by clicking cscript and then running vbs. But still I get the same error.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
J_Coder
  • 707
  • 5
  • 14
  • 32
  • How exactly are you invoking the script? – Ansgar Wiechers Jul 15 '19 at 10:11
  • 1
    If you follow this guide http://support.sas.com/kb/60/322.html are you certain they are installed? are the 32 or 64 bit drivers installed? – Nick.Mc Jul 15 '19 at 10:19
  • 1
    There are many other suggestions besides the cscript one in your link - your error indicates it can't find the driver - are you certain the 32 bit version is installed? – Nick.Mc Jul 15 '19 at 10:22
  • 1
    Also an entry in the _User DSN_ tab doesn't mean anything. You need to check the _Drivers_ tab – Nick.Mc Jul 15 '19 at 10:24

0 Answers0