使用vba禁用单元格内容检测

我需要知道如何禁用使用VBA的单元格内容检测,因为当我从* .CSV文件导入数据时,我不想在“date格式”中获取date,即使我指定它只是文本import。 我想把string作为date。 如果我尝试更改格式后导入我得到一个数字,而不是与date的string。

Cells.Select Selection.NumberFormat = "@" 'importo los datos With ActiveSheet.QueryTables.Add(Connection:=datosConexion, Destination:=Range("$A$1")) .name = archivo .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 = False .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = True .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) .TextFileDecimalSeparator = "." .TextFileThousandsSeparator = "," .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With 

你需要改变:

 .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) 

对于包含需要导入为date的date的列xlTextFormatreplace为1