importing a text file into Excel.

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
 
E

Eddie

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top