Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
#38617
Ao tentar conectar à uma planilha do próprio arquivo, utilizando a conexão de string abaixo no VBA Excel, aparece o erro:
Erro em tempo de execução '-2147467259(80004005)':
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.
#38678
Olá! Estou postando a solução apresentada no grupo do whats :).

Estava faltando um ";" antes do Extended:
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.Path & "\LISTA PILOTO.xlsm" & _
"Extended Properties=""Excel 12.0;HDR=Yes"";"
End Sub

O código passou a ficar dessa maneira:
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.Path & "\LISTA PILOTO.xlsm" & _
";Extended Properties=""Excel 12.0;HDR=Yes"";"
End Sub

Muito agradecido pela prontidão.

Atte.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord