Remove File from Excel Recent Documents

KeithGargett

New Member
Joined
Sep 2, 2019
Messages
6
Hello,

I have had this piece of code within a few macros for a while and it has been working fine.
The VBA project has not been modified at all.
As far as i know nothing has changed with our company excel install, version etc. but it has suddenly started causing errors. Anyone know why, or alternative code to do the same task?

I get a file not found error (which i don't understand because the file in question is open & active), and the debug takes me to "If Len(Dir(f.Name)) = 0 Then"
the purpose of this piece of code is to remove a "Statistics" workbook from another tool used by multiple users, the code opens, writes to and closes the workbook in question.

Thanks in advance.

Code:
               Const ReviewEntry As Boolean = False
               Dim f As RecentFile
                    For Each f In Application.RecentFiles
                       If Len(Dir(f.Name)) = 0 Then
                           f.Delete
                       ElseIf ReviewEntry Then
                            Debug.Print f.Name
                            Stop
                        End If
                    Next
                ActiveWorkbook.UpdateLinks = xlUpdateLinksAlways
                ActiveWorkbook.Save
                ActiveWorkbook.Close
 
Last edited by a moderator:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,832
Messages
6,121,853
Members
449,051
Latest member
excelquestion515

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