Macro That Will Open the Most Recently Used File in Excel

Last reviewed: November 4, 1994
Article ID: Q72445
The information in this article applies to:
  • Microsoft Excel for Windows, versions 3.0, 4.0, 5.0
  • Microsoft Excel for OS/2, version 3.0

SUMMARY

The File menu in Microsoft Excel contains a list of the four most recently used files. The following macro will open the first file in that list:

   A1: =GET.BAR()
   A2: =GET.BAR(A1,"File",GET.BAR(A1,"File","file list"))
   A3: =MID(A2,4,LEN(A2)-3)
   A4: =OPEN(A3)
   A5: =RETURN()

Explanation

A1: Finds the number of the menu bar that is currently displayed. A2: Returns the first item from the recently used file list, exactly

    as it appears on the File menu.
A3: Strips off some unnecessary text that is not part of the filename. A4: Opens the file.

REFERENCES

"Microsoft Excel User's Guide 1," version 4.0, page 55

"Microsoft Excel User's Guide 2," version 4.0, pages 289-290

"Microsoft Excel User's Guide," version 3.0, pages 73 and 649-650


KBCategory: kbprg kbmacro
KBSubcategory:

Additional reference words: 3.0 3.00 4.0 4.00 5.0 5.00


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 4, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.