Ask a Question

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

seafalcon
Contributor

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"]);

}
Find the faith in life
3 REPLIES 3
seafalcon
Contributor

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. 
Find the faith in life
seafalcon
Contributor


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)));

  

Find the faith in life


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.
--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: