
Tips.Net > WordTips Home > Macros > VBA Examples > Determining the Size of a File
Summary: Need to know how many bytes are used by a file? This VBA code will figure it out for you. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)
One of the nice things about writing macros is that you have the ability to do just about anything you can do using the regular Basic language. For instance, you may want to open and process some file within a macro. Before doing so, you might want to know how large that file is. You can figure this out using the FileLen function in VBA. It returns the length of a specific file, in bytes. You don't even have to open the file first; just provide a file name, and FileLen does the rest. The following is an example:
lFLen = FileLen("TargetFile.txt")
This code determines the length of the TargetFile.txt file, and assigns that value to lFLen. The value returned is a long integer.
Tip #820 applies to Microsoft Word versions: 97 2000 2002 2003
Great Idea! Uncover the many ways you can master the full potential of printing your documents. WordTips: Printing and Printers can help you get the most from both the printed page and your printer.
Have thousands of WordTips at your fingertips, on your own system. Answer your own questions or help support others. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Pet Tips
Word2007 Tips
WordTips