Copying only required string from txt file to excel sheet

S

sangram

Hi ,
i am preparing one report in excel sheet. For which i got txt file
as input. Which contains some strings. but, my interest is in particular
format of string or line. For example
File name - tst.txt
L1 -> return (&SUP_GPTA_TC_GROUP[channel].TCCTRL_reg);
L2 -> D:\p\S83\C01\iiii\zzz\00\XXX\yyy.h 2423 Info
826: Suspicious pointer-to-pointer conversion (area too
small) <D.23:
Use pointers as declared (EXPR)>
 
J

Joel

Sub Gettext()

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Set fsread = CreateObject("Scripting.FileSystemObject")
FName = Application.GetOpenFilename("All files (*.*),*.*")

Set fread = fsread.GetFile(FName)
Set tsread = fread.OpenAsTextStream(ForReading, TristateUseDefault)

RowCount = 1
Do While tsread.AtEndOfStream = False

InputLine = tsread.ReadLine
If InStr(InputLine, "D:\p\S83\") > 0 Then
Range("A" & RowCount) = InputLine
RowCount = RowCount + 1
End If

Loop
tsread.Close
End Sub
 
Top