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.
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
Re: Locate shortcuts for a file?
Quote:
Originally Posted by
westconn1
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.
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.