Microsoft KB Archive/72445

{|
 * width="100%"|

Macro That Will Open the Most Recently Used File in Excel

 * }

-

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,&quot;File&quot;,GET.BAR(A1,&quot;File&quot;,&quot;file list&quot;)) 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.