Ao tentar conectar à uma planilha do próprio arquivo, utilizando a conexão de string abaixo no VBA Excel, aparece o erro:
Não foi possível encontrar ISAM instalável.
Código
Option Explicit
Public cn As ADODB.Connection
Public rs As ADODB.Recordset
Public i As Long
Public sql As String
Public ws As Worksheet
Public Sub ConectarPlan()
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.Path & "\LISTA PILOTO.xlsm" & _
"Extended Properties=""Excel 12.0;HDR=Yes"";"
End Sub
Public Sub DesconectarPlan()
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
Public Sub Importar_Pendentes()
ConectarPlan
sql = "SELECT * FROM [DB$]"
rs.Open sql, cn, adOpenStatic, adLockReadOnly, adCmdText
Set ws = shtPendente
With ws
.Select
.Cells.Clear
.Range("A1").Select
End With
For i = 0 To rs.Fields.Count - 1
Cells(1, i + 1) = rs.Fields(i).Name
Next i
Range("A2").CopyFromRecordset rs
Cells.Columns.AutoFit
DesconectarPlan
End Sub
Poderiam me dar uma luz de como resolver tal problema, estou utilizando o Excel 365 de 32 bits.
Desde já muito agradecido.