
Tips.Net > WordTips Home > Files > Determining If the End of a Text File Has Been Reached
Summary: When writing a macro that processes a text file, you may need to know when the end of the file has been reached. This is easy to do with the EOF function, described in this tip. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)
In other issues of WordTips you learn how to access text files from within a macro. Another command associated with sequential text files is the EOF function. If used on an open file, EOF returns a True or False condition, which indicates if the internal file pointer is located at the end of the file. This function is most often used when inputting information from a text file, as shown here:
Open "MyFile.Dat" for Input as #1
J = 0
While Not EOF(1)
J = J + 1
Line Input sMyString(J)
Wend
Tip #1397 applies to Microsoft Word versions: 97 2000 2002 2003 2007
Ultimate Library! The most amazing collection ever offered in the history of WordTips places every tip—present and historical—at your fingertips. Check out the WordTips Ten-Year Library.
Do you want a decade of WordTips information at your fingertips? You can find what you need with the WordTips Ten-Year Library. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips