importing a text file into Excel.

  • Thread starter Thread starter Mili
  • Start date Start date
M

Mili

Hi,
I am trying to import a text file into Excel. I am using
following code. How to proceed ???
I am using Office 2000.

code :
---------------------------------------------------------
Public Sub DisplayLastLogInformation()
Const LogFileName As String = "C:\test\test.txt" 'content
of test file are column1,column2,column3,column4,clumn5
Dim FileNum As Integer, tLine As String
FileNum = FreeFile ' next file number
Open LogFileName For Input Access Read Shared As
#FileNum ' open the file for reading
Do While Not EOF(FileNum)
Line Input #FileNum, tLine ' read a line from the
text file
Loop ' until the last line is read
Close #FileNum ' close the file
MsgBox tLine, vbInformation, "Last log information:"
End Sub
 
-----Original Message-----
Hi,
I am trying to import a text file into Excel. I am using
following code. How to proceed ???
I am using Office 2000.

code :
---------------------------------------------------------
Public Sub DisplayLastLogInformation()
Const LogFileName As String = "C:\test\test.txt" 'content
of test file are column1,column2,column3,column4,clumn5
Dim FileNum As Integer, tLine As String
FileNum = FreeFile ' next file number
Open LogFileName For Input Access Read Shared As
#FileNum ' open the file for reading
Do While Not EOF(FileNum)
Line Input #FileNum, tLine ' read a line from the
text file
Loop ' until the last line is read
Close #FileNum ' close the file
MsgBox tLine, vbInformation, "Last log information:"
End Sub
---------------------------------------------------------

Regards

Mili
.
This will open a text file in Excel.

sub opentextfile()

workbooks.opentext filename:= "c:\test.xls", Tab :=True,_
Thousandsseparator=","


end sub
 
Back
Top