recent files in a list box

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Cross posted https://www.excelforum.com/excel-pr...cently-open-files-in-listbox.html#post5110185

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
I would like to see a answer to this question if there is one.
The other site only allows seeing answers if you log in.
So if you get a answer please post it here.
 
Upvote 0
My version of Excel errors if maximum is set above 50

Test unaltered first and then try amending to 60

Code:
Private Sub ListBox1_GotFocus()
    Application.RecentFiles.Maximum = [COLOR=#ff0000]50[/COLOR]
    ListBox1.Clear
    Dim i As Integer
    For i = 1 To [COLOR=#ff0000]50[/COLOR]
        On Error GoTo TheEnd
        ListBox1.AddItem Application.RecentFiles(i).Path
    Next
TheEnd:
End Sub

For the Name without path
Code:
ListBox1.AddItem Application.RecentFiles(i).Name
 
Upvote 0
That worked for me:
Thanks.

What does this line of code do:
Application.RecentFiles.Maximum =
50



My version of Excel errors if maximum is set above 50

Test unaltered first and then try amending to 60

Code:
Private Sub ListBox1_GotFocus()
    Application.RecentFiles.Maximum = [COLOR=#ff0000]50[/COLOR]
    ListBox1.Clear
    Dim i As Integer
    For i = 1 To [COLOR=#ff0000]50[/COLOR]
        On Error GoTo TheEnd
        ListBox1.AddItem Application.RecentFiles(i).Path
    Next
TheEnd:
End Sub

For the Name without path
Code:
ListBox1.AddItem Application.RecentFiles(i).Name
 
Last edited:
Upvote 0
posted something here in error oops!
 
Last edited:
Upvote 0
My version of Excel errors if maximum is set above 50

Test unaltered first and then try amending to 60

Code:
Private Sub ListBox1_GotFocus()
    Application.RecentFiles.Maximum = [COLOR=#ff0000]50[/COLOR]
    ListBox1.Clear
    Dim i As Integer
    For i = 1 To [COLOR=#ff0000]50[/COLOR]
        On Error GoTo TheEnd
        ListBox1.AddItem Application.RecentFiles(i).Path
    Next
TheEnd:
End Sub

For the Name without path
Code:
ListBox1.AddItem Application.RecentFiles(i).Name

what about this idea, that the recently opened files should be saved into a textfile, and the files should be retrieved from the text file. is it possible?
 
Upvote 0
@yinkajewole - perhaps you did not see my solution in post#4 :confused:

using a listbox, how do i let it display up to 60 recently opened files
@My Aswer Is This confirmed that the solution posted works well
Q1 Did you test it?

what about this idea, that the recently opened files should be saved into a textfile, and the files should be retrieved from the text file. is it possible?
Q2 Why would this be helpful? Are you wanting a longer list than Excel maintains?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top