Results 1 to 2 of 2

Thread: Need to create shortcut in recent items location

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2015

    Smile Need to create shortcut in recent items location

    Hello VB Gurus,
    I have an Outlook 2010 VBA code that copies the currently highlighted email in inbox to a local drive ( D: ) on my laptop.

    I execute this macro via a button on my quick access toolbar on outlook.

    I need some sort of VBA code that also creates a shortcut to this email in the recent items location.

    Basically, here are the steps i need to achieve.

    1 & 2 are achieved, I need macro for the 3rd point below.

    1. Highlight an email in my outlook inbox
    2. Copy it to a specific location in my D drive.
    3. Create a shortcut to this item in recent items folder, so that if i need to upload this email somehwere I can locate it easily from recent items ( C:\Users\tkumar1\AppData\Roaming\Microsoft\Windows\Recent )

    Thanks for your assistance.

  2. #2
    Join Date
    Dec 2004

    Re: Need to create shortcut in recent items location

    Set wshshell = CreateObject("Wscript.Shell")
    ' select shortcut name and folder
    Set oshelllink = wshshell.CreateShortcut(wshshell.specialfolders("recent") & "\aaa.lnk") ' change name of link to suit
    'Set the Target Path for the shortcut
    oshelllink.TargetPath = "c:\somepath\file.msg"    ' change name of file to open as required
    'Set the additional parameters for the shortcut
    ' oshelllink.Arguments = "c:\windows\desktop\aaa.txt"  ' probably not required in this instance
    'Save the shortcut
    'Clean up the WshShortcut Object
    Set oshelllink = Nothing
    Set wshshell = Nothing
    note: while is is very simple to add the shortcut to the recent documents folder, this will not push the shortcut to the list that is displayed when you click on recent documents, to do that you will need to edit the recent docments MRU list in the registry, do you want to get that carried away? it may be better to just open the saved item in the default application and allow windows to update the recent documents list for you
    Last edited by westconn1; Apr 22nd, 2016 at 04:19 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed

Tags for this Thread

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