Text Importer

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hello,

I saw a previous post on this and obtained the following code. After
execution of the code, the code runs without any errors but the data from the
file whic is selected for import does not "paste" or import to the
destination cell of A1. Any ideas of why this might be?

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & fname, _
Destination:=Range("A1"))
.Name = shfname
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.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, 2, 2, _
2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
'.Refresh BackgroundQuery:=False
End With
 
1) I suspect a lot of the properties in that list can be deleted as they'r
probably default
2) check that the file hasnt' got blank lines at the beginning...thes ewould
cause the apparent offset
 
Thanks, the file does not contain any blank rows. At the completion of the
code, the text from the chosen file which is suppossed to have been imported
does not show up on the destination sheet. I am unsure why this is? When I
recreate the code with the macro recorder, it seems there is nothing
different from my code and the what the recorder creates except the text
appears on the sheet.
 
Back
Top