Is this a bug...?

DominicB

Well-known Member
Joined
Oct 3, 2005
Messages
1,569
Hi all

I have been playing with the .RecentFiles property and have come across an oddity. The code below will remove the second item from your recently used files list (under the File menu) - assuming you have a second file there, and do not have your maximum flag set to 1 or 0 :

Sub test()
Application.RecentFiles(2).Delete
End Sub

When run this code will do what's intended, but it will also decrease your number of recently used files to show (Tools > Options, General) by 1. This flag is controlled by the Application.RecentFiles.Maximum instruction so shouldn't happen. Is this a bug (or a known issue) or am I missing something?

This is Excel 2003, Windows Pro XP (both SP2)

DoimnicB
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Perhaps, (itr being the index number of the item you wish to remove),

Code:
Sub test()
Dim MRUCount As Integer, itr As Integer
itr = 2
With Application.RecentFiles
    If .Count >= itr Then
        MRUCount = .Count
        .Item(itr).Delete
        .Maximum = MRUCount
    End If
End With
End Sub
 
Upvote 0
Hi HOTPEPPER

Thanks for your reply. I tried using a workaround similar to yours - capturing the ,Maximum value, deleting the entry and resetting the .Maximum, but couldn't get it working properly. Strangely, it seems to work OK if you reference the entry via the Item method as you have done.

Thanks again

DominicB
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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