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
| Sub Macro2()
'
' Macro2 Macro
'
'
ActiveWorkbook.Queries.Add Name:="Export (2)", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Excel.Workbook(File.Contents(""C:\Users\Toto\Desktop\Source.xlsx""), null, true)," & Chr(13) & "" & Chr(10) & " Export_Sheet = Source{[Item=""Export"",Kind=""Sheet""]}[Data]," & Chr(13) & "" & Chr(10) & " #""En-têtes promus"" = Table.PromoteHeaders(Export_Sheet, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & " #""Type modifié"" = Table.TransformColumnTypes(#""En-têtes promus"",{{""Champ1 "", type text}" & _
", {""Column2"", type any}, {""Column3"", type any}, {""Column4"", type any}, {""Column5"", type any}, {""Column6"", type any}, {""Column7"", type any}, {""Column8"", type any}, {""Column9"", type any}, {""Column10"", type any}, {""Column11"", type any}, {""Column12"", type any}, {""Column13"", type any}})" & 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=""Export (2)"";Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [Export (2)]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Export__2"
.Refresh BackgroundQuery:=False
End With
End Sub |
Partager