Out of memory error sur TextFileColumnDataTypes

J'ai une macro qui charge un fichier CSV. Elle fonctionne bien (Office365):

Set conData = Application.ActiveWorkbook.Connections("...").TextConnection

conData.Connection = ...

Si j'essaie de définir le format des colonnes, elle plante avec le message "Out of memory error" sur la ligne suivante (donc avant de lire le fichier):

conData.TextFileColumnDataTypes = Array(xlTextFormat)

Quelqu'un a une idée ?

Merci

Hello !

Est-ce que c'est possible d'avoir ton code en entier ?

(dans des jolies balises de code :D )

Dim conData As TextConnection

Set conData = Application.ActiveWorkbook.Connections("...").TextConnection

conData.Connection = "TEXT;" & "..."

conData.TextFilePlatform = -535 ' -535 = UTF-8

'Next line OK: indeed, it's shown in watch as Variant/Varian(1 to 1)

conData.TextFileColumnDataTypes(1) = xlTextFormat

'Next line not OK: subscript out of range

conData.TextFileColumnDataTypes(2) = xlGeneralFormat

'Next line not OK: Out of memory

conData.TextFileColumnDataTypes = Array(xlTextFormat, xlGeneralFormat, xlTextFormat, xlTextFormat, xlTextFormat, xlGeneralFormat, xlTextFormat)

Rechercher des sujets similaires à "memory error textfilecolumndatatypes"