I'm trying to figure out a way to read the first line of text in a .txt through excel VBA without opening the file, something I've been having trouble finding since all the examples I've seen involve opening the .txt one way or another.
Aside from this, I was wondering if there was any way for me to get the VBA code to delete the mentioned .txt a set time after excel has been closed... which I'm not too sure is even remotely possible (with VBA at least).
EDIT:
The simplified code goes like this:
Option Explicit
Public g_strVar As String
Sub Test_Proc()
Dim row as Long
row = 2
Do While Cells(row, 1) <> ""
Cells(row, 2) = ImportVariable(Cells(row, 1))
row = row + 1
Loop
End Sub
Function ImportVariable(strFile As String) As String
Open strFile For Input As #1
Line Input #1, ImportVariable
Close #1
End Function
Column 1 contains the locations of each and every .txt file, and on the column next to it I have to detail what is the first line of text on each file. Problem is that the list has been in a couple occasions about 10K long, and the only place I can think of from where I can improve on the time this takes to execute is in the "Open / Close" since some of these .txt files are 12.000 KB in size and take a bit to open.