CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2000
    Posts
    4

    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]


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    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.


  3. #3
    Join Date
    Jan 2000
    Posts
    4

    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.


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    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...


  5. #5
    Join Date
    May 1999
    Posts
    3,332

    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.


  6. #6
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    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
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  7. #7
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090

    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





  8. #8
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    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!
    ----------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured