Our training courses

Other training resources

Our training venues

Why we are different

Details for latinbui

latinbui has participated in the following threads:

Added by latinbui on 20 Feb 2022 at 15:17

Hello,

Thank you for posting the video. I tried using the sample Excel files that came with the video. When I run the program to populate the listbox using data from the Movies.xlsx file, I received the following error:

1. Run-time error '-2147467259 (80004005)': Failure creating file

Private Sub UserForm_Initialize()

    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    
    Set cn = New ADODB.Connection
    
    cn.ConnectionString = _
        "Provider=Microsoft.ACE.OLEDB.12.0;" & _
        "Data Source=" & ThisWorkbook.Path & "\Movies.xlsx;" & _
        "Extended Properties='Excel 12.0 Xml;HDR=YES';"

    cn.Open
    
    Set rs = New ADODB.Recordset
    
    rs.ActiveConnection = cn
    rs.Source = _
        "SELECT [Title], [Release Date], [Run Time] FROM [Sheet1$] " & _
        "WHERE [Title] LIKE '%star%' ORDER BY [Title]"
        
    rs.Open
    
    With ListBox1
        .ColumnCount = rs.Fields.Count
        .ColumnWidths = "300;50;50"
        .List = WorksheetFunction.Transpose(rs.GetRows)
    End With
    
    rs.Close
    cn.Close
    
End Sub

This error most likely occurred at the VBA line: cn.open

 

I am using Excel Office 365 with Windows 10 64-bit and Microsoft OneDrive. The path to the Movies.xlsx file in OneDrive has the following extension:

https://d.docs.live.net/

 

References to the following libraries have been turned on in the Excel VBA Editor-Tools\References menu:

1. Visual Basic for Applications

2. Microsoft Excel 16.0 Object Library

3. OLE Automation

4. Microsoft Office 16.0 Object Library

5. Microsoft ActiveX Data Objects 6.1 Library

I am not sure whether the problems in creating the ADO connection has to do with the connection string, the OneDrive path, or the object library references in Excel.

Thank you

Head office

Kingsmoor House

Railway Street

GLOSSOP

SK13 2AA

London

Landmark Offices

99 Bishopsgate

LONDON

EC2M 3XD

Manchester

Holiday Inn

25 Aytoun Street

MANCHESTER

M1 3AE

© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.

End of small page here
Please be aware that our website uses cookies!
I'm OK with this Tell me more ...