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 28 29 30 31 32 33 34 35 36
| Option Explicit
Public Const Fld_DB = "chemin"
Public Const Name_DB= "NomFichier.xlsx"
Public Const Fld_DBL = Fld_DB & Name_DB
Public Const DB_Connect As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Fld_DBL
Sub test()
Dim tp As Variant
tp = Xls_SqlLoader(DB_Connect)
End Sub
Public Function Xls_SqlLoader(ByVal strConnection As String) As Variant
Dim rst As ADODB.Recordset
Dim Cn As ADODB.Connection
Dim Sql_Tx As String
'--- Connection ---
Set Cn = New ADODB.Connection
With Cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = strConnection & ";Extended Properties=""Excel 12.0; HDR=YES"""
.Open
End With
Sql_Tx = "SELECT NomTable1, NomTable2 from FUNDS WHERE NomTable1= 'Bidule' "
Set rst = New ADODB.Recordset
Set rst = Cn.Execute(Sql_Tx)
Xls_SqlLoader = 0
Cn.Close
End Function |
Partager