I really hope i can get your help. Ive been searching high and low for what is probably a simple solution.
We have hundreds of txt files that all relate to cnc programs. Unfortunately there has been a historical lack of control in keeping a strict numbering system for parts and operations.
I have to extract the 3rd and 4th line of txt from each file into an excel doc so we can remunerate some and catalogue all for referencing.
So far the closest thing i've found to what i'm after is in the thread
Extract a single line of data from numerous text files and import into Excel
however i cannot make it work - my excel knowledge is good but not with macros. the start of every txt file is
#1 <blank line>
#2 %
#3 O00000 (part description)
#4 (part descriptio)
#5 rest of program.
. . . as requested ive included the code i'm trying to modify.
Private Sub CommandButton1_Click()
Dim filename As String, nextrow As Long, MyFolder As String
Dim MyFile As String, text As String, textline As String, prog As String
MyFolder = "M:\CNC Programs\Haas lathe programs\Haas ST30 programs\Programs\Programs in .txt format"
MyFile = Dir(MyFolder & "*.txt")
Do While MyFile <> ""
Open (MyFolder & MyFile) For Input As #1
Do Until EOF(1)
Line Input #3, textline
text = text & textline
Loop
Close #1
MyFile = Dir()
Debug.Print text
nextrow = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheet1.Cells(nextrow, "A").Value = Mid(text, prog)
text = "" 'reset text
Loop
End Sub