Forum Discussion
tmahender12
10 years agoFrequent Contributor
its not working
getting error at
MyExcelRecords = DDT.ExcelDriver("C:\MyDir\MyExcel.xls");altemann
10 years agoContributor
What error are you getting?
- tristaanogre10 years agoEsteemed Contributor
My sample code I gave was intended to be pseudo-code and not necessarily something to be implemented as is.
Looking over what I wrote, if you're going to use the JScript language (which is what I was using) it should look like this:function GetCol1Unique(); { var MyExcelRecords; MyExcelRecords = DDT.ExcelDriver("C:\\MyDir\\MyExcel.xls"); MyExcelRecords.ADOCommandObject.CommandText = "SELECT DISTINCT Col_1 from MyExcel.xls"; return MyExcelRecords; }Note that the pathing needs to use double backslashes as the backslash is a special character for use in strings in JScript.
But, as mentioned, it would be helpful to know what the error is that you're getting.- tmahender1210 years agoFrequent Contributor
iam using vbscript,its getting runtime error in vbscript
- altemann10 years agoContributor
I've never worked with VBScript, so I'm not sure if that's how you'll get your return but something like this should work then:
Function Test Call DDT.ExcelDriver("C:\ExcelFile.xls", "Sheet1") DDT.CurrentDriver.ADOCommandObject.CommandText = "SELECT DISTINCT Col_1 from MyExcel.xls" Test = DDT.CurrentDriver.Value 'Kills the driver DDT.CloseDriver(DDT.CurrentDriver.Name) End Function