Please find my problem regarding accessing text file below:There are set of text (.txt format) files in a folder. I need toopen each file and search for a string in each file. I am to createan instance to folder and get the file but not able to open them.Please suggest on the same.Sub Filetext1()Dim x As ObjectSet x = CreateObject("Scripting.FilesystemObject")Set y = x.Getfolder("C:\AS400 Sessions")For Each file In y.Filesname1 = file.Name 'I am getting the name correctly'I need to open each file and search for text hereNextMsgBox (Count)End Sub
From a quick Google search, it appears that it is the FileSystemObject thathas the open method. I.e. something likeDim FileStream As ObjectSet FileStream = x.opentextfile("C:\Batch\" & file.Name)However, there might be other ways too.
as long as you have the full file name you don'tactually need to use the filesystem object.Try googling or using the help and look for "LineInput".