Results 1 to 6 of 6

macro returns error "Method 'Open' of object '_Recordset' failed"

Threaded View

Leafgreen macro returns error "Method... 08-03-2009, 12:10 AM
royUK Re: problem using Vlookup... 08-03-2009, 02:45 AM
Leafgreen Re: macro returns error... 08-04-2009, 04:17 AM
Leafgreen Re: macro returns error... 08-09-2009, 03:49 AM
Richard Schollar Re: macro returns error... 08-09-2009, 05:18 AM
Leafgreen Re: macro returns error... 08-09-2009, 05:40 AM
  1. #1
    Registered User
    Join Date
    08-02-2009
    Location
    c:\Wonderland
    MS-Off Ver
    Excel 2007
    Posts
    5

    Question macro returns error "Method 'Open' of object '_Recordset' failed"

    Re: http://www.excelforum.com/excel-prog...ml#post2138532, this is *exactly* the issue that I have. I think Djvice was working with the same UPC db file that I dl from the web, too. I loaded the files in the zip on that thread and got the lookup macro to work fine.

    But then I tried with my data file. The dl data file "items.csv" has 1,048,571 rows of data. I renamed djvice.xls to mylookup.xls. I edited the macro to this
    Sub aaa()
      Range("B:C").ClearContents
      Set cn = CreateObject("adodb.connection")
      Set rs = CreateObject("adodb.recordset")
      
      cn.Open "provider=microsoft.jet.oledb.4.0;data source = C:\Documents and Settings\Lenovo_User\My Documents\My Data Sources\upcdirectory;extended properties = ""text; hdr=yes"""
      For Each ce In Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row)
      
        rs.Open "select size,description from items.csv where UPC = " & ce.Value, cn, 3, 3
        Cells(ce.Row, 2).CopyFromRecordset rs
        rs.Close
      Next ce
      
      
      
      Set rs = Nothing
      Set cn = Nothing
      
    End Sub
    where items.csv is my data file. For the header, in the first three cells of the first row of this data file I have inserted "UPC", "size" and "description". When I run the macro I get this error message from MS VB:
    Run-time error '-2147467259 (80004005)':
    Method 'Open' of object '_Recordset' failed


    Help, please. TIA
    Last edited by Leafgreen; 08-03-2009 at 04:32 AM. Reason: title correction

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