I have created a Visual Basic script in Excel to open, grab contents and close a number (more than one hundred) of Word documents.
Part of the code is:
Private Function GrabTextFile(ByVal file_name As String) As String Dim fnum As Long fnum = FreeFile() Open file_name For Input As #fnum GrabTextFile = Input$(LOF(fnum), #fnum) Close #fnum End Function
(The rest of the code is heavily based on this page from VB helper.)
The script fails on line:
GrabTextFile = Input$(LOF(fnum), #fnum)
with the message:
Run-time error '62': Input past end of file
It fails on document 34. However, if I remove that specific document and then rerun the script, it fails on the new document at that location. This implies to me that I have a problem freeing some memory(?).
Since these are Word documents, I suggest you try the
GrabWordFile function instead of the
GrabTextFile function listed on that VB Helper page.