Forum Discussion

seafalcon's avatar
seafalcon
Contributor
15 years ago

Run time error when using ACD driver to access an Excel File (Office2007 installed )

 Why Microsoft Jscript runtime error thrown?

The excel file is pretty standard..No clue...





/////////////////////////////////Code as below///////////////////////////////////////////////////////


var RecNo;

  

// Posts data to the log (helper routine) 

function ProcessData()

{

  var Fldr, i;

  

  Fldr = Log["CreateFolder"]("Record: " + aqConvert.VarToStr(RecNo));

  Log["PushLogFolder"](Fldr);

  

 // if (! (DDT["CurrentDriver"]["Exists"]) )

  //  Log["Warning"]("MS Word is closed"); 

  

  for(i = 0; i < DDT["CurrentDriver"]["ColumnCount"]; i++) //This line throw exception, but why>?

    Log.Message("helloworld"); 

    Log.Message(DDT["CurrentDriver"]["ColumnName"](i) + ": " + aqConvert.VarToStr(DDT["CurrentDriver"]["Value"](i)));

  

  Log["PopLogFolder"](); 

  RecNo = RecNo + 1; 

}

  

// Creates the driver (main routine) 

function TestDriver()

{

  var Driver;

  

  // Creates the driver 

  // If you connect to an Excel 2007 sheet, use the following method call: 

  // Driver = DDT["ExcelDriver"]("C:\\MyFile.xls", "Sheet1", true); 

  Driver = DDT["ExcelDriver"]("C:\\MyFile.xls", "Sheet2"); 

  

  // Iterates through records 

  RecNo = 0;

  while (! Driver["EOF"]() ) 

  {

    ProcessData(); // Processes data 

    Driver["Next"](); // Goes to the next record 

  }

  

  // Closing the driver 

  DDT["CloseDriver"](Driver["Name"]);

}
  • I am worried about the testscript format. It seems if I input an empty line into the testscript, replay gotta fail. Is it because script language is unstable to execute?



    I also attached MyFile.xls



    Hope someone could help me out. 

  • One more thing, if the Ts like this, it's executable without exception



    for(i = 0; i < DDT["CurrentDriver"]["ColumnCount"]; i++) 

        Log.Message(DDT["CurrentDriver"]["ColumnName"](i) + ": " + aqConvert.VarToStr(DDT["CurrentDriver"]["Value"](i)));

      



    However, if I input an extra line between, it will throw exception.. why? I am not a VBscript master.. In java, this shouldn't throw any exception.. I am beat!




    for(i = 0; i < DDT["CurrentDriver"]["ColumnCount"]; i++) 





        Log.Message(DDT["CurrentDriver"]["ColumnName"](i) + ": " + aqConvert.VarToStr(DDT["CurrentDriver"]["Value"](i)));

      


  • Hi Philip,





    Your code works without exceptions for me. Could you please send us the entire project suite folder containing script units with both the problematic code and the code of creation of a DDT driver? Please contact us directly via the Contact Support form.