Article ID: 109113
Article Last Modified on 10/10/2006
Option Explicit
Sub MostRecentlyUsedFileList()
'Dimension the array to hold the file list
Dim files(4)
Dim arraypos, begin As Integer
Dim item As String
'Initialize a pointer for the array
arraypos = 0
'Find the position of the File List menuitem. This will be used as a
'starting location in the list of menuitems on the File menu.
begin = MenuBars("Worksheet").Menus("file").MenuItems("file list").Index
'Begin loop that continues until it encounters the divider line that
'follows the end of the file list
Do Until MenuBars("Worksheet").Menus("file").MenuItems(begin).Caption = "-"
'Place the name of the menuitem into the variable called Item.
'This name will include the ampersand, the number of the file in
'the list, a space, then the file name itself.
item = MenuBars("Worksheet").Menus("file").MenuItems(begin).Caption
'Remove the first three characters of Item and place name in array
files(arraypos) = Mid(item, 4, Len(item) - 3)
'Increment counter for menuitem and pointer in array
begin = begin + 1
arraypos = arraypos + 1
Loop
'opens the first file on the most recently used list
Workbooks.Open filename:=files(0)
'displays the name of the third file on the most recently used list
MsgBox files(2)
End Sub
Keywords: kbprogramming KB109113