reading Excel data via vbscript & ado

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hey all. I have worked out how to read a single excel cell with a
script and ado, but I cant figure out how to read multiple cells
without opening and closing the ado recordset multiple times. Can
someone help? I know I dont have to use ado to read data from excel,
but I specifically want to do it that way. Heres my code so far, and
all this does is read a single cell and display the value in a message
box...I will do other stuff with those values once I figure out how to
do multiple cells:

'----------------------------------------------------------------------------
On Error Resume Next

Const adOpenStatic = 3
Const adLockOptimistic= 3
Const adCmdText= &H0001
Set objConnection= CreateObject("ADODB.Connection")
Set objRecordSet= CreateObject("ADODB.Recordset")
my_Path= "\\server1\spreadsheets\"
my_File= "data.xls"
Target_file= my_Path & my_File

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=" & Target_file & ";Extended Properties=""Excel
8.0;HDR=No;"";"
objRecordset.Open "Select * from [sheet1$B14:C14]",objConnection,
adOpenStatic, adLockOptimistic, adCmdText
Do While Not (objRecordset.EOF)
msgbox OME_File & " Description:" & vbCRLF &
objRecordset.Fields(0).Value
objRecordset.MoveNext
Loop
objRecordset.Close
objConnection.Close

'----------------------------------------------------------------------------

.



Relevant Pages

  • Re: VB 6 and MS SQL Server 2000 - (Yudkin)
    ... Since you have multiple SELECT statement, ... If I need to use ADO, what components do I have to include in my project? ... GetClipString is an RDO API. ... SQL SP's have no concept of event flows. ...
    (microsoft.public.vb.general.discussion)
  • Re: commandBuilder Update SQL generation for > 1 table?
    ... > allow updates of ad-hoc queries in a data grid involving multiple ... In old school ado, you'd have a bitch of a time grabbing a ... recordset from SQL Server and having it elegantly created in excel. ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: VlookupS-Alan Beban
    ... Paste the code in a module, then enter the formula in a cell within the ... "Ashish Mathur" wrote: ... > The following procedure will give you the resukt in multiple rows of the ... It is bringing back only the first occurance. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: cell phone booster
    ... plans for people like me with extremely low cell use. ... Multiple lines, multiple long distance, multiple voice mail, multiple ... part cut out of the mix because I have a 3rd party no-fee plan for that. ...
    (sci.electronics.design)
  • Re: Change + to -
    ... Place -1 in an empty cell ... Edit, Paste Special, Multiply ... Progression of multiple changes to a constant ...
    (microsoft.public.excel.misc)