title: VBScript to read from individual cells in Excel, Automation or ADODB?
body: <p>not a coder, and first time asking a question... so go easy please!  Using VBScript here in an application for on air graphics.</p>
  
  <p>I have two methods that work for reading data from an excel spreadsheet.  I think they are called Automation and ADODB Connection.</p>
  
  <p>I can get both to work, but here's the catch: Automation is slower, but it can read individual cells easily.  ADODB is super fast, but I can't point to individual cells, only columns.  Does that make sense?</p>
  
  <p>I would love to be able to use ADODB to read individual cells.  Am I crazy?</p>
  
  <p>Here is my code:</p>
  
  <p>AUTOMATION (works, but take 10 seconds):</p>
  
  <pre><code>Dim SelectedboxSpreadsheet
  
      'InputBox: ask for spreadsheet
      Dim shell : Set shell = CreateObject("Shell.Application")
      Dim boxSpreadsheet : Set boxSpreadsheet = shell.BrowseForFolder(0, "Select box Spreadsheet:", &amp;H4000, "%SystemRoot%\explorer.exe")
      SelectedboxSpreadsheet = boxSpreadsheet.self.path
  
  Dim objExcel
  Dim currentWorksheet
  Dim Cells
  
  Sub OpenExcelSheet(SheetNumber)
      Set objExcel = CreateObject("Excel.Application")
      objExcel.Workbooks.open SelectedboxSpreadsheet, false, true
      Set currentWorksheet = objExcel.ActiveWorkbook.Worksheets(SheetNumber)
      Set Cells = currentWorksheet.Cells 
  End Sub
  
  Sub CloseExcelSheet()
      objExcel.Workbooks.Close
      objExcel.Quit
      Set currentWorkSheet = Nothing
      Set objExcel = Nothing
      Set Cells = Nothing
  End Sub
  
  
  Call OpenExcelSheet("box")
  
      TrioCmd("page:set_property H111 " &amp; (Cells(2,2).Value))
      TrioCmd("page:set_property I111 " &amp; (Cells(2,8).Value))
      TrioCmd("page:update")
  
  Call CloseExcelSheet
  </code></pre>
  
  <p>And ADODB (works, but can't read specific cells, have to format the spreadsheet like a table):</p>
  
  <pre><code>Dim SelectedSpreadsheetFromTxt
  
  Dim fso
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set file =fso.OpenTextFile("C:\ProgramData\vizrt\Trio\WorldCupDrawSpreadsheetPath.txt")
  Do Until file.AtEndOfStream
  line = file.ReadLine
  Loop
  file.Close
  
  SelectedSpreadsheetFromTxt = line
  
  dim objConnection, objRecordSet
  
  set objConnection = CreateObject("ADODB.Connection")
  set objRecordSet = CreateObject("ADODB.Recordset")
  
  objConnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;" &amp;_
  "Data Source=" &amp; SelectedSpreadsheetFromTxt &amp; ";" &amp;_
  "Extended Properties=""Excel 12.0; HDR=Yes; IMEX=1"";"
  
  dim A1name,A1tri,A2name,A2tri,A3name,A3tri,A4name,A4tri
  
  objRecordSet.Open "SELECT * FROM [Trio Data Group A$]", objConnection
  
  Do Until objRecordSet.EOF
     A1name = objRecordSet.Fields.Item("A1name")
     A1tri = objRecordSet.Fields.Item("A1tri")
     A2name = objRecordSet.Fields.Item("A2name")
     A2tri = objRecordSet.Fields.Item("A2tri")
     A3name = objRecordSet.Fields.Item("A3name")
     A3tri = objRecordSet.Fields.Item("A3tri")
     A4name = objRecordSet.Fields.Item("A4name")
     A4tri = objRecordSet.Fields.Item("A4tri")
  
     TrioCmd("page:set_property 0006 " &amp; A1tri)
     TrioCmd("page:set_property 0007 " &amp; A2tri)
     TrioCmd("page:set_property 0008 " &amp; A3tri)
     TrioCmd("page:set_property 0009 " &amp; A4tri)
  
     TrioCmd("page:set_property 0401 " &amp; A1name)
     TrioCmd("page:set_property 0411 " &amp; A2name)
     TrioCmd("page:set_property 0421 " &amp; A3name)
     TrioCmd("page:set_property 0431 " &amp; A4name)
  
  objRecordSet.MoveNext
  Loop
  </code></pre>
  
  <p>Anyway, this seems like a shot in the dark, but any advice would be appreciated... thanks!!!</p>