How to get the most recently used document to be opened automatically when you open Word
Article contributed by Astrid Zeelenberg, Dave Rado and Will Rickards
1. |
Using a command line switch to open the most recently used documentYou can open Word and have the most recently used (MRU) file opened
automatically by clicking on the Windows Start button, selecting Run,
and typing: The /m switch normally means “run a macro called [whatever follows the m]”, but it can also be used to run almost any WordBasic command, and “File1” is the WordBasic command to open the MRU file. The only WordBasic commands which don't appear to work when following the /m switch are those which rely on a document already being open. Alternatively, you can create a new shortcut to Word; right-click on it and select Properties; and on the Shortcut tab, where it says “Target”, add /mFile1 to the end of the path, so it looks like this: "C:\Program Files\Microsoft Office\Office\WINWORD.EXE" /mFile1 Make sure that the path of Winword.exe is still set to the folder where Office is installed. You can now use the new shortcut when you want to start Word with the most recently used file and your usual shortcut when you don't. However, note that using the /m switch prevents any AutoExec macros you may have from running. Also, if the MRU file is inaccessible or has been deleted or renamed, this method won't find the most recently used file that does exist; it will just create a blank document. If you want it to open the most recently used valid file, or if you don't want to disable your AutoExec macros, you'll need to use a macro. |
2. |
Using a macro to open the most recently used document whenever Word opensPaste the following code into a Global template and it will run automatically whenever Word opens:
Sub AutoExec() The AutoExec macro opens the first valid file that's listed in the MRU (Most Recently Used) list: For more on AutoExec macros see: Writing application event procedures. Note that if you also want the selection to return to your last editing point, you can add the line: Application.GoBack ... just after the line: RecentFiles(1).Open
|
3. |
Using a macro to open the most recently used document whenever Word is opened from its icon, but not when you open Word by launching a filePaste the following code into a module in a Global template: Option Explicit Public Function CmdLinetoString(ByVal
lngPtr As Long) As
String Again, if you also want the selection to return to your last editing point, just add the line: Application.GoBack ... immediately after the line: RecentFiles(1).Open
|
4. |
The Application.GoBack bug and how to get round itSee the article: GoBack (Shift+F5) doesn't work in some newly-opened documents |