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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| Sub Transport()
Dim Num_Feuille As String
Dim cn As WorkbookConnection
' ============================================================== chargement des données sources
'--------------------------------------------------------------- chargement Fournisseur
ActiveWorkbook.Queries.Add Name:="request_sql_15", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(File.Contents(""E:\OneDrive\Mister-gadgets\000000 Developpement\Fichiers source\Fichiers import site\request_sql_15.csv""),[Delimiter="";"", Columns=5, Encoding=1252, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & " #""En-têtes promus"" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & " #""Type modifié"" = Table.TransformColumnTypes(#""E" & _
"n-têtes promus"",{{""id_supplier"", Int64.Type}, {""name"", type text}, {""date_add"", type datetime}, {""date_upd"", type datetime}, {""active"", Int64.Type}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Type modifié"""
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=request_sql_15;Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [request_sql_15]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "request_sql_15"
.Refresh BackgroundQuery:=False
End With
'-------------------------------------------------------------- affectation nom feuille
Num_Feuille = ActiveSheet.Name
Sheets(Num_Feuille).Name = "Fournisseur"
'-----------------------------------------------------------------Transporteur
ActiveWorkbook.Queries.Add Name:="request_sql_16", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(File.Contents(""E:\OneDrive\Mister-gadgets\000000 Developpement\Fichiers source\Fichiers import site\request_sql_16.csv""),[Delimiter="";"", Columns=25, Encoding=1252, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & " #""En-têtes promus"" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & " #""Type modifié"" = Table.TransformColumnTypes(#""" & _
"En-têtes promus"",{{""id_carrier"", Int64.Type}, {""id_reference"", Int64.Type}, {""id_tax_rules_group"", Int64.Type}, {""name"", type text}, {""url"", type text}, {""active"", Int64.Type}, {""deleted"", Int64.Type}, {""shipping_handling"", Int64.Type}, {""range_behavior"", Int64.Type}, {""is_module"", Int64.Type}, {""is_free"", Int64.Type}, {""shipping_external"", " & _
"Int64.Type}, {""need_range"", Int64.Type}, {""external_module_name"", type text}, {""shipping_method"", Int64.Type}, {""position"", Int64.Type}, {""max_width"", Int64.Type}, {""max_height"", Int64.Type}, {""max_depth"", Int64.Type}, {""max_weight"", type text}, {""grade"", Int64.Type}, {""date_import"", type datetime}, {""id_shop"", Int64.Type}, {""id_lang"", Int64." & _
"Type}, {""delay"", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Type modifié"""
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=request_sql_16;Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [request_sql_16]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "request_sql_16"
.Refresh BackgroundQuery:=False
End With
'-------------------------------------------------------------- affectation nom feuille
Num_Feuille = ActiveSheet.Name
Sheets(Num_Feuille).Name = "Transporteur"
'----------------------------------------------------------------- destruction des connexions
For Each cn In ActiveWorkbook.Connections
cn.Delete
Next cn
'==============================================Traitement
'----------------------------------------------------------------- destruction des feuilles de travail
Sheets(F_Fournisseur).Select
ActiveWindow.SelectedSheets.Delete
Sheets(F_Transporteur).Select
ActiveWindow.SelectedSheets.Delete
End Sub |
Partager