Link to home
Start Free TrialLog in
Avatar of psueoc
psueocFlag for United States of America

asked on

Advanced Hyperlink in Excel - Hyperlink to EXE specifying file to open

In Windows you can create a shortcut to the Internet Explorer executable and then after the path add a web address you'd like the browser to open to.  For example, the shortcut path would look like:

"C:\Program Files (x86)\Internet Explorer\iexplore.exe" http://www.google.com/

I'd like to do something similar in Excel with a hyperlink in a cell.  I have a portable version of VLCPlayer in the root of my flash drive and an Excel document further in the drive.  I'd like to point to the EXE of the portable VLC and then specify a path to a video file it should open.  In the desktop shortcut example above, my shortcut would look something like:

"..\..\..\VLCPortable\VLCPortable.exe"  ..\..\videos\file.mp4

Does anyone know if this is possible or of another way to accomplish this?  I can't depend on the user having VLC player installed, so I need to point to the portable EXE included on the flash drive.
ASKER CERTIFIED SOLUTION
Avatar of redmondb
redmondb
Flag of Afghanistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of psueoc

ASKER

Assuming I can make the links/paths relative instead of static, this might actually work.  I'll give it a quick try and let you know the results.  Thanks.
Avatar of psueoc

ASKER

redmondb,

Your idea was 99% of what I needed.  The batch worked on its own with relative paths but when i linked to it in Excel it wasn't working.  I changed the Echo to On and added a Pause at the end to inspect things.  Turns out the relative paths were pointing to different locations when the batch was run from Excel.  I did a quick google search and discovered I needed to add a %~dp0 to the beginning of the paths.  The %~dp0 points to the batch file's path...from there the relative links know where to go.

So, for example...

Prior to adding the %~dp0 the batch file was:
"..\..\..\VLCPortable\VLCPortable.exe" "..\..\videos\file.mp4"

All I needed to add was a %~dp0 to the paths:
"%~dp0..\..\..\VLCPortable\VLCPortable.exe" "%~dp0..\..\videos\file.mp4"

Thanks for the great idea.  I really appreciate your help.
Thanks, psueoc.

(My absolute paths were only only an example. The correct absolute paths should work fine.)