bonjour j'ai fais une macro qui m'ouvre un fichier csv et qui le converti au format adequat, j'ai ajoute un commandbutton pour que lorsque je clique dessus ca se lance automatiquement.

quand je clique dessus il me fais rechercher le fichier , il ouvre un nouveau classeur mais la il me met une erreur voici le sceen qui peut m'eclaircir s'il vous plait merci d'avance

salutations

PS: l'erreur est en rouge.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Private Sub CommandButton2_Click()

Dim F As Variant
  
F = Application.GetOpenFilename("csv Files (*.csv), *.csv")
  
If F = False Then Exit Sub
 
Workbooks.Add
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & F, Destination _
        :=Range("$A$1"))        
        .Refresh BackgroundQuery:=False
        .Name = "fichier_client"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 65001
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = True
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
        2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 5, 2)
        .TextFileTrailingMinusNumbers = True
        End With