How to clear recent used document list from window through VB
How to clear the recent used files in windows through VB. I m opening word file at background.
thanks
Mail me : [email protected]
Re: How to clear recent used document list from window through VB
if you use Word 2000, you can use the Word object model.
Application.RecentFiles is the collection of the recent file list.
Iterate over all elements and call the Delete method of each element.
Re: How to clear recent used document list from window through VB
By doing this,it clear the recent document list in MSWord but i m not able to do that for documents in start menu.
Other option I saw in MSDN is using reference of
Declare sub shaddtorecentdocs lib "Shell32.lib" (Byval uflags as long,byval pv as string)
call shaddtorecentdocs(2,vbnullstring)
But in this case i m not able to find any such reference of "shaddtorecentdocs" in API library. if u can halp me out on this i will be thankful to u.
Re: How to clear recent used document list from window through VB
your declare statement is wrong.
use the following code
private Declare Sub shaddtorecentdocs Lib "Shell32.dll" Alias "SHAddToRecentDocs" (byval uflags as Long, byval pv as string)
private Sub Command1_Click()
Call shaddtorecentdocs(2, "m:\lah.htm")
End Sub
This is for ADDING documents to the recent file list...
Re: How to clear recent used document list from window through VB
to delete from the shell's recent file list, get the location of the folder via ShGetFolderLocation (CSIDL_RECENT) API, then delete all relevant link files in that directory using VB's kill command.
A bit of knowledge from Past
:-)
Have a nice day, TheGreat, wherever
Cesare Imperiali
:-)
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Re: How to clear recent used document list from window through VB
'Make reference to Microsoft Scripting Runtime
private Sub Command1_Click()
Dim fo as Folder, fs as FileSystemObject, file1 as File
Dim FullPath as string
FullPath = "c:\windows\recent\"
set fs = CreateObject("Scripting.FileSystemObject")
set fo = fs.GetFolder(FullPath)
on error resume next
for Each file1 In fo.Files
Debug.print file1.Name
file1.Delete true
next
Err.Clear
End Sub
Re: How to clear recent used document list from window through VB
This code works: (taken from API-Guide with slight changes)
Const CSIDL_RECENT = &H8
Const MAX_PATH = 260
private Type SHITEMID
cb as Long
abID as Byte
End Type
private Type ITEMIDLIST
mkid as SHITEMID
End Type
private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (byval hwndOwner as Long, byval nFolder as Long, pidl as ITEMIDLIST) as Long
private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (byval pidl as Long, byval pszPath as string) as Long
private Sub Form_Load()
Dim RecentFolder as string
me.AutoRedraw = true
RecentFolder = GetSpecialfolder(CSIDL_RECENT)
set fs = CreateObject("Scripting.FileSystemObject")
set fo = fs.GetFolder(RecentFolder)
on error resume next
for Each file1 In fo.Files
file1.Delete true
next
Err.Clear
End Sub
private Function GetSpecialfolder(CSIDL as Long) as string
Dim r as Long
Dim IDL as ITEMIDLIST
r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If r = NOERROR then
Path$ = Space$(512)
r = SHGetPathFromIDList(byval IDL.mkid.cb, byval Path$)
GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
Exit Function
End If
GetSpecialfolder = ""
End Function
----------
The @host is everywhere!
----------