English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Dear friend,if you're familiar with VBA,please help me in this case. How to control a .txt file in Excel's VBA function?
I don't find any API of VBA for text file, just as we do such as :
set ppt as PowerPoint.application
However I dont know which macro class is designed for .txt file,
Could anybody told me how?? Given codes is perfect!

2007-04-13 17:49:58 · 3 answers · asked by Michael 2 in Computers & Internet Programming & Design

3 answers

You should be fine to use any VB api...Below is the code you require. I tested it using a file on C drive called Demo.txt.

Sub ShowFileContent()
Dim objLineText As String
Dim objCurrLine As Integer
objCurrLine = 0
Open "C:\Demo.txt" For Input As #1
Do Until EOF(1)
Input #1, objLineText
MsgBox "Line " & objCurrLine & " - " & objLineText
objCurrLine = objCurrLine + 1
Loop
Close #1
End Sub

2007-04-13 19:45:08 · answer #1 · answered by Abraham Alex 4 · 1 0

Open Excel first. Open the .txt document from the document menu. stick to the import education. make positive you examine Delimited click next elect the nature that delimits the columns click end Voila - you've imported your first actual delimited textual content document.

2016-12-04 00:19:05 · answer #2 · answered by Anonymous · 0 0

You can get some help from
http://expert.myitcareer.org/

2007-04-13 18:46:53 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers