Summary:
Procedure allows your VB app to interact with the Windows Recent Documents List. You can clear the Recent Documents list and/or add a file to the list.

Arguments:
ClearList - Boolean: True to Clear the list, otherwise False
FilePath - Optional. Enter path of file you wish to add to the list

VB Code:
  1. 'declare api procedures
  2.     Public Declare Sub SHAddToRecentDocs Lib "shell32.dll" _
  3.         (ByVal uFlags As Long, _
  4.         ByVal pv As String)
  5.  
  6. 'declare constants
  7.     Public Const SHARD_PATHA = &H2&
  8.  
  9.  
  10. Public Sub RecentDocs(ClearList as Boolean, Optional FilePath as Variant)
  11.     'clear docs list?
  12.     If ClearList then SHAddToRecentDocs 0, CLng(0)
  13.  
  14.     'add file to docs list?
  15.     If Not IsMissing(FilePath) Then SHAddToRecentDocs SHARD_PATH, FilePath
  16. End Sub

Usage Example:
VB Code:
  1. 'To clear Recent Documents List:
  2. RecentDocs True
  3.  
  4. 'To clear list then add a file to it:
  5. RecentDocs True, "c:\AddToRecentDocsList.txt"
  6.  
  7. 'To append file to the list:
  8. RecentDocs False, "c:\AddToRecentDocsList.txt"

Notes:
As written, this code is intended to be placed in a module, and then called as needed. In order to place this code in a form, you will have to change the API and Constant declarations to 'Private'