PDA

View Full Version : Get name of shortcut.lnk that called application



RickinNS
01-29-2016, 11:11 AM
Is there any way to pass the name of a desktop shortcut.lnk to the program it called at runtime? For example; all users have two shortcut icons on their desktops pointing to the same Access database. They will be presented with specific forms depending on which .lnk they activated. Is there a function available to capture the name of the link? Suggestions abound on how to change a desktop link but none suggest how you can get the name of the calling lnk icon.

jonh
01-29-2016, 01:32 PM
Add a command line arg to the shortcut target.


"C:\MyDatabase1.accdb" /cmd "MyArg"


Then check the command


select case Command()
case "MyArg"
case else

Edit

So, I would say the answer is no.

What would be the difference between a shortcut or using shell in vba or the win run exe?

They are all the same. A name is not generally required so it would'nt make sense to try and obtain one.

RickinNS
01-29-2016, 03:35 PM
I attempted to include the path to Access in the target without success:
"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" "C:\FW\MyDatabase.accde" /cmd "55"
However; removing the reference to Access from the target works as expected. Can you explain why the reference to Access creates a problem?

Also; how do you retrieve the argument "55" once you have opened Microsoft Access. I attempted to put the code in a module and it complained "Command()" was outside the procedure.

Thank you for you help.

Rick in NS

jonh
01-29-2016, 03:41 PM
You don't want to include the path to Access unless you want problems after an upgrade to a new version.

You need to add the code to an event procedure in a form module. A button click event for eg.

RickinNS
01-29-2016, 04:03 PM
Excellent! Thank you for your help.