home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 October / pcp156b.iso / handson / files / copyhelp.exe / clnhist / CleanHistory.bas next >
Encoding:
BASIC Source File  |  1999-07-17  |  1.1 KB  |  24 lines

  1. Attribute VB_Name = "CleanHistory"
  2. ' Cleans history on file menu - if file cannot be seen, it is removed from the list.
  3. Sub CleanRecentFileList()
  4. Dim rf As RecentFile, FullName As String
  5. Const CLEARABSENTNETDOCS As Boolean = True      ' Change to False to retain docs on absent network drives
  6. Const CLEARABSENTREMOVABLES As Boolean = True   ' Change to False to retain docs on absent removable drives
  7.     For Each rf In RecentFiles
  8.         FullName = rf.Path & Application.PathSeparator & rf.Name
  9.     
  10.         If FullName = Application.PathSeparator And CLEARABSENTNETDOCS Then ' Probably absent network drive
  11.             rf.Delete
  12.         Else
  13.             On Error Resume Next    ' VBA raises error if file is on absent removable disk
  14.             If Dir(FullName) = "" Then
  15.                 If (Err.Number <> 0 And CLEARABSENTREMOVABLES) Or (Err.Number = 0) Then
  16.                     rf.Delete
  17.                 End If
  18.                 Err.Clear
  19.             End If
  20.             On Error GoTo 0 ' Reinstate normal VBA error handling
  21.         End If
  22.     Next
  23. End Sub
  24.