I’m trying to read a text file that has 1147 lines. The code below is only reading lines 1050-1147. My goal is to read the entire file and pull out the specific values located on various lines to use within a script. An example would be the value 2 from the line containing “BlockList: 2”. I've included a snippet of the format of the text file as it's formatted differently than any example that I've come across (lines 1116-1128); The values I'm trying to access are indented the same as the first line shown (not sure if that matters).
fixation.OffsetTime: 426611 *** LogFrame End *** Level: 2 *** LogFrame Start *** Procedure: TestProc BlockList: 2 BlockList.Cycle: 1 BlockList.Sample: 2 Running: BlockList *** LogFrame End ***
Level: 1 * LogFrame Start * Experiment: ChoiceofLotteries_fMRI_I The code so far:
Sub OpenTextFileTest() Const ForReading = 1, ForWriting = 2, ForAppending = 3 Dim fs, f, contents, var1 Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.OpenTextFile("C:\NameOfFile.txt", 1) contents = f.ReadAll f.Close Debug.Print contents End Sub