ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   excel 2000 & importing text files (https://www.excelbanter.com/excel-programming/309304-excel-2000-importing-text-files.html)

antinoz

excel 2000 & importing text files
 
I have used a query table to import a text file with fixed widths in excel
2003 on my home computer.
But when I open the file at work which uses office 2000 my text document is
loaded into one cell, instead of the supposed 4 cells & not starting at A1
but D1.
I have tried changing the fixed width array and the column data types to no
avail. can anyone say why this will work in office 2003 but not 2000?? and
make any suggestions??

the code:

Sub Getfile()
Dim fname As String
fname = Application.GetOpenFilename _
(filefilter:="Text Files(*.txt),*.txt,All Files (*.*),*.*")


If fname = "False" Then
MsgBox "You Did'nt select a file"
Exit Sub
End If

Set myquery = Workbooks(1).Worksheets(2)
Set muncb = myquery.QueryTables _
.Add(Connection:="TEXT;" & fname, _
Destination:=myquery.Cells(1, 1))
With muncb
.TextFileParseType = xlFixedWidth
.TextFileFixedColumnWidths = Array(10, 10, 10, 10)
.TextFileColumnDataTypes = _
Array(xlTextFormat, xlTextFormat, xlTextFormat, xlTextFormat)
.Refresh
End With

End Sub

Thanks Anthony


All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com