- Recovering More of Your Work with a Shorter AutoRecover Interval
- Automatically Saving Your Work Frequently
- Closing a Document Without Saving
- Closing All Your Open Documents
- Making Backups as You Work
- Showing More Items on the Recent Documents List
- Opening the Most Recently Used Document at Startup
- Clearing the Recent Documents List
- Creating and Opening Document Workspaces
- Automatically Prompting for Document Properties
- Creating a Trusted Location for Documents
- Viewing Total Editing Time Updated in Real-Time
- Calculating Billable Time Charges
- Locking Document Formatting
- Preventing Untracked Changes
- Setting Up a Document for Structured Editing
- Inspecting a Document for Personal Information
- Viewing Two Documents Side by Side
- Updating All Fields Automatically
Opening the Most Recently Used Document at Startup
Word's RecentFiles object represents the collection of most recently used files displayed in the Recent Documents list. Each item on this list is a RecentFile object. You specify a RecentFile object by using RecentFiles(Index), where Index is an integer that specifies the file you want to work with. The most recently used file is 1, the second most recently used file is 2, and so on.
When you close a Word session, the document you last made changes to becomes the most recently used document. There's a good chance that you'll want to continue working on that document the next time you start Word. Therefore, it would be handy to have Word open the most recently used file each time you start the program.
If you want Word to run some code each time it's started, open the Visual Basic Editor (either by choosing Developer, Visual Basic or by pressing Alt+F11), click the Normal project in the Visual Basic Editor's Project Explorer, and then create a new module (by choosing Insert, Module) named AutoExec. In this module, create a Sub procedure named Main and enter your code in that procedure. Listing 3.6 shows such a procedure:
Listing 3.6. A Procedure That Opens the Most Recently Used Document
Sub Main() Application.RecentFiles(1).Open End Sub