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
| Sub filePicker()
Dim fdialog As Office.FileDialog
Dim fs As Variant
Set fdialog = Application.FileDialog(msoFileDialogFilePicker)
With fdialog
.Filters.Add "All zip Files", "*.zip", 1
.AllowMultiSelect = False
If .Show Then
fs = .SelectedItems(1)
If fs <> "" Then
MsgBox "Fichier choisi : " & fs, vbOKOnly, "Sélection d'un fichier zip"
ImporterCSV ()
End If
End If
End With
Set fdialog = Nothing
End Sub
Sub ImporterCSV()
Dim chemin: Dim fichier As String
chemin = ActiveWorkbook.Path & "\APAC\"
ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & chemin & fichier, Destination:=Range("$A$1"))
.Name = fichier
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Range("A2").Select
End Sub |
Partager