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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 

DominicB

Well-known Member
Joined
Oct 3, 2005
Messages
1,569
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
 

Forum statistics

Threads
1,136,927
Messages
5,678,621
Members
419,776
Latest member
mikelowski

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
Top