Error en Macro - Abrir archivo plano en un libro Excel establecido.

Por favor me puedes ayudar revisando la macro adjunta con la
que pretendo abrir el contenido de un archivo plano desde una ubicación
específica en una hoja Excel en la celda A1.
Dim strNombreArchivo
strNombreArchivo = Application.GetOpenFilename
If strNombreArchivo = False Then Exit Sub
With ActiveSheet.QueryTables.Add(Connection:= _
strNombreArchivo, Destination:=Range( _
"$A$1"))
.Name = "DECLARA"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
De antemano muchas gracias por la ayuda y tiempo

Respuesta
1

Cambialo por esto:

Sub Abre_Txt()
Dim strNombreArchivo
strNombreArchivo = Application.GetOpenFilename
If strNombreArchivo = False Then Exit Sub
 With ActiveSheet.QueryTables.Add(Connection:= _
 "TEXT;" & strNombreArchivo _
 , Destination:=Range("$A$1"))
 .Name = "DECLARA"
 .FieldNames = True
 .RowNumbers = False
 .FillAdjacentFormulas = False
 .PreserveFormatting = True
 .RefreshOnFileOpen = False
 .RefreshStyle = xlInsertDeleteCells
 .SavePassword = False
 .SaveData = True
 .AdjustColumnWidth = True
 .RefreshPeriod = 0
 .TextFilePromptOnRefresh = False
 .TextFilePlatform = 850
 .TextFileStartRow = 1
 .TextFileParseType = xlDelimited
 .TextFileTextQualifier = xlTextQualifierDoubleQuote
 .TextFileConsecutiveDelimiter = False
 .TextFileTabDelimiter = True
 .TextFileSemicolonDelimiter = False
 .TextFileCommaDelimiter = False
 .TextFileSpaceDelimiter = False
 .TextFileColumnDataTypes = Array(1)
 .TextFileTrailingMinusNumbers = True
 .Refresh BackgroundQuery:=False
 End With
End Sub
 Suerte

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas