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:
'declare api procedures Public Declare Sub SHAddToRecentDocs Lib "shell32.dll" _ (ByVal uFlags As Long, _ ByVal pv As String) 'declare constants Public Const SHARD_PATHA = &H2& Public Sub RecentDocs(ClearList as Boolean, Optional FilePath as Variant) 'clear docs list? If ClearList then SHAddToRecentDocs 0, CLng(0) 'add file to docs list? If Not IsMissing(FilePath) Then SHAddToRecentDocs SHARD_PATH, FilePath End Sub
Usage Example:
VB Code:
'To clear Recent Documents List: RecentDocs True 'To clear list then add a file to it: RecentDocs True, "c:\AddToRecentDocsList.txt" 'To append file to the list: 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'


Reply With Quote