excelvbaruntime-erroradodbisam

Getting a "Could not find installable ISAM" error for a program using ADODB to export information from a separate excel sheet


I am trying to write a program that you can select a closed file and have information extracted from it without ever opening it. I am not sure why I keep getting an error.

For context I had a simpler version of this program that I copied from "Wise Owl" on youtube that was working but doesn't work anymore either for some reason.

See below for an example of my code. If anyone could tell me what I am missing that would be great.

Sub GetDataFromClosedFile()
Dim cn As ADODB.Connection
Dim file As FileDialog
Dim sItem As String
Dim GetFile As String

Set file = Application.FileDialog(msoFileDialogFilePicker)
With file
    .Title = "Select a File"
    .AllowMultiSelect = False
    '.InitialFileName = strPath
    If .Show <> -1 Then GoTo NextCode
    sItem = .SelectedItems(1)
End With
NextCode:
    GetFile = sItem
    Set file = Nothing

Sheet1.Range("A1").CurrentRegion.Offset(1, 0).Clear

Set cn = New ADODB.Connection

cn.ConnectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source= GetFile" & _
"Extended Properties='Excel 12.0 Xml;HDR=YES';"

cn.Open
cn.Close

Solution

  • Change the connection string assignment to this:

    cn.ConnectionString = _
    "Provider=Microsoft.ACE.OLEDB.12.0;" & _
    "Data Source=" & GetFile & ";" & _
    "Extended Properties='Excel 12.0 Xml;HDR=YES';"