+ Reply to Thread
Results 1 to 3 of 3

query excel from vbscript

Hybrid View

pelegk2 query excel from vbscript 12-29-2009, 05:24 AM
romperstomper Re: query excel from vbscript 12-29-2009, 06:18 AM
pelegk2 Re: query excel from vbscript 12-29-2009, 06:25 AM
  1. #1
    Registered User
    Join Date
    11-30-2004
    Location
    Israel
    Posts
    4

    query excel from vbscript

    i succed in query number of rows in excel file, but i can't make a query on certin column, or get the value of certin column ,
    this is the code i have
    Const adOpenStatic = 3 
    Const adLockOptimistic = 3 
    
    filename = "D:\temp\rbsupport\final\file.xls" 
    Set cn = CreateObject("ADODB.Connection") 
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filename & ";Extended Properties=Excel 8.0" 
    
    query = "Select count(*) as cnt from [internal$A4:B9] " 
    Set rs = CreateObject("ADODB.Recordset") 
    rs.Open query, cn, adOpenStatic, adLockOptimistic 
    
    Do Until rs.EOF 
      WScript.Echo rs.Fields.item(0) 
      rs.MoveNext 
    Loop
    what do i need to change to make a group by on certin columns, or just to make a select on certin columns
    thanks
    Peleg
    Israel the best place to live in - after heaven (but no one wants to go there so fast - )

    http://www.networked-toys.com

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,016

    Re: query excel from vbscript

    If you don't have column headers, you will need to use F1, F2 etc to refer to the fields you want according to their position.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    11-30-2004
    Location
    Israel
    Posts
    4

    Re: query excel from vbscript

    thnaks alot
    that what i was looking for, the default alias name of the column which starts with "F"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1