Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Autres importer donnees externes

gh4

XLDnaute Occasionnel
bonjour a toutes et tous (excel 2003)
Je voudrai importer des données externes en csv depuis mon dossier Téléchargement
dans ma macro enregistrée par excel 2003 ci dessous je n'ai pas le choix pour choisir le fichier dans téléchargement
pourriez vous m'aider
Merci

Sub Macro3()
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\xx\Downloads\xxx.csv", Destination:=Range("A1"))
.Name = "xxx"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = -535
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub

Cordialement
 

don_pets

XLDnaute Occasionnel
Hello,

Tu peux passer par GetOpenFilename avec un truc du genre

VB:
    Dim Fichier As String
    Dim BDD As Workbook
    Dim SRC As Workbook
    Dim DestRange As Range
    
    Fichier = Application.GetOpenFilename("Fichiers CSV (*.csv),*.csv")
    Set BDD = ThisWorkbook
    Set DestRange = BDD.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
    
    With BDD.Sheets(1).QueryTables.Add(Connection:="TEXT;" & Fichier, Destination:=DestRange)
        .TextFileParseType = xlDelimited
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = True
        .Refresh
    End With
 
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…