1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
Public conn As ADODB.Connection
Sub ouvre_connection(SrcFile As String)
' SrcFile est le chemin + le nom du fichier à ouvrir
Dim str As String
Set conn = New ADODB.Connection
If Len(SrcFile) > 0 Then
SrcFile = Replace(SrcFile, "http://", "\\")
SrcFile = Replace(SrcFile, "/", "\")
'--- Connection ---
With conn
.Provider = "Microsoft.ACE.OLEDB.16.0;"
.ConnectionString = "Data Source=" & SrcFile & ";Extended Properties=""Excel 12.0;IMEX=1;HDR=NO"""
End With
'-----------------
conn.CursorLocation = adUseClient
If conn.State = 0 Then
conn.Open ' C'est sur cette instruction que le code génère une erreur
End If
End If
End Sub |
Partager