How to Open a Word document with VBA when the file path is to a Windows Explorer shortcut RRS feed

  • Question

  • I am developing a Word-based solution in VBA that needs to process multiple Word documents each time it runs. There will be multiple versions of each input document. Only one version of each input will be processed on each run, but it could be any of the versions--it doesn't have to be the latest version. For a variety of reasons, I want to use a fixed name for each input file. One reason is to avoid prompting the user for multiple files every time.

    A fixed name means one of: asking the user to rename files, or copy and rename files, or create a properly named shortcut (.lnk) for each input file.

    I prefer the shortcut solution, but Documents.Open() will not work with a path to a shortcut. I can't find any information anywhere about how to recognize and process (or transparently process) a Windows Explorer shortcut.

    I'm currently working in Word 2010, but it also needs to work in Word 2007.


    Can I do this somehow?

    • Edited by Gerrie Shults Tuesday, March 15, 2011 10:28 PM improved clarity
    Tuesday, March 15, 2011 10:26 PM


  • Hi math70,

    Thanks for posting in the MSDN Forum.

    According to your description, you want to read out the shortcut’s TargetPath property to open the word document. Do you want to do that?

    If it is what you want, please use this snippet to read out the target path of the shortcut and use it to open the word document.


    Dim sc As WshShortcut
      Dim wsch As New WshShell
      Set sc = wsch.CreateShortcut("[You ShortCut Path]")
    'Now you can get the target path use this senetnce 'sc.TargetPath'


    You need to import “Window Script Host Object Model” in the VBA project.

    Have a good day,


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 17, 2011 8:06 AM