Results 1 to 4 of 4

Thread: Locate shortcuts for a file?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    183

    Locate shortcuts for a file?

    Is it possible using the FileSystemObject (or any other method) to determine if/where there are shortcuts to a specific file?

    I'm being asked to look into building a system to automate updating data in an Excel document for one of my clients, and they want to always retain the original file. The client has asked that each document should have the date the file was created in the name of the file. My concern is if the user is using a shortcut to open the document, would it be possible to locate all shortcuts that refer to the current document and relink/replace them with shortcuts to the new document.

    My alternative would be to keep a standard name for the current document, duplicate it and rename the duplicate to indicate it is an older copy, and then replace the current document with the updated document. I would prefer to do this, but if they insist on including the date in the name of the file, then I would have to deal with a user who is using a shortcut to that document.

    Thanks for any help/suggestions anyone can provide.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Locate shortcuts for a file?

    there is no way to find all shortcuts to a file, short of testing every file on the hdd with extension .lnk to see if that workbook is the target

    it may be possible using API to get command line arguments, to identify the shortcut that opened the workbook so that it can be updated, but if there could be multiple shortcuts that will not help

    if the original filename is changed the shortcut can point to non existent target, so will not open anything, just an annoyance to the user

    edit: on further consideration another option might be to put code in the original workbooks open event to open the latest file and close self, this may entail saving the the name of the latest file, or checking all files in a folder for newest
    Last edited by westconn1; Jan 21st, 2011 at 03:26 PM.
    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
    pete

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    183

    Re: Locate shortcuts for a file?

    Quote Originally Posted by westconn1 View Post
    there is no way to find all shortcuts to a file, short of testing every file on the hdd with extension .lnk to see if that workbook is the target

    it may be possible using API to get command line arguments, to identify the shortcut that opened the workbook so that it can be updated, but if there could be multiple shortcuts that will not help

    if the original filename is changed the shortcut can point to non existent target, so will not open anything, just an annoyance to the user

    edit: on further consideration another option might be to put code in the original workbooks open event to open the latest file and close self, this may entail saving the the name of the latest file, or checking all files in a folder for newest
    Thanks for the suggestions, and the verification that I expected that there isn't a way to do this.

    It's an interesting suggestion to save the 'current' file name, althogh I'm not sure if it could cause more problems than it's worth (Just in case they change the name of the file). Depending on how they want this to work, I may be able to instruct them to keep this in it's own directory, with a sub-directory for all 'archived' files. On startup, if there's more than one document in the folder (aside from the 'Update' file) I could try to verify which one is correct.

    Thanks again for the input.

  4. #4
    Fanatic Member dmaruca's Avatar
    Join Date
    May 2006
    Location
    Jacksonville, FL
    Posts
    577

    Re: Locate shortcuts for a file?

    Definitely one way to keep people from using shortcuts is to constantly change the file name like with a date and moving the old one. You might want to consider also renaming the old file to Name(archive).xls. This would prevent windows from being "helpful" and quickly relocating the old file in the subdirectory.

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