Welcome toWord.Tips.Net
Ask a Word Question
Make a Comment
Learn Access Now
Free Printable Forms
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips
Collapsing and Expanding Subdocuments
As you are programming your macros, you may have a need to determine if a particular file exists on disk. For instance, the purpose of your macro may be to open and read from a text file. Before doing so, you will want to check to see if the file exists, in order to avoid an error.
The following WordBasic function can be used to check for the existence of a file. All you need to do is pass it the full filename as a string, and the macro returns either True (if the file exists) or False (if it doesn't).
Function FileThere(FileNm$)
FileThere = (Files$(FileNm$) > "")
End Function
You can use the function similar to the following:
If FileThere("c:\myfile.txt") Then
'
' Do stuff here
'
End If
Tip #818 applies to Microsoft Word versions: 6 95
Add a Professional Finishing Touch! Word includes great tools that allow you to add professional-grade finishing touches to your documents. You can add indexes, tables of contents, and other special tables by using the detailed information available in this volume.