Excel (2010) HYPERLINK: how to call a file with command line arguments and spaces in the path?

I am working on an Excel-document to make a (project-)folder structure manageable, using HYPERLINKs to important files and folders (Word/Excel, etc.).

Since we are also using TFS, I want to add the possibility to check out and check in right from within the Excel sheet. The one-stop landing and overview page.

If I simply have

=HYPERLINK("C:\work\TF.exe";"simple test")

I get a security warning, but the program executes.

In the end, I want something like

=HYPERLINK("C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\TF.exe status $/MyProject/Documents /recursive";"Find local Check Outs in Document folder")

However, this does not work for spaces in the file path and also for the command line arguments. Is there any way to make this run without using VB? Even if I wrap parts of the hyperlink with quotes (using double double quotes for Excel: "" -> ") does not improve anything, I get "file not found" error.

And.. only only only if I have to use VB (I do not like the security warning), what would be the best way to do this?


An alternative is to create a shortcut with the relevant command line switches embedded in it. Then you can hyperlink to the shortcut. Note that the shortcut has a .lnk extension.

If you'd like to do something more involved than launching a single executable with switches, you could link to a batch script (.bat).


As far as I know, it is not possible to use HYPERLINK like that - except with the nice trick of anthony.

However, spaces in the hyperlink don't matter as long as the path is in quotes.

To solve this you might have to use VBA, if the command-line parameters have to be dynamic or if you don't want to use anthonys approch for other reasons.

This would be a neat fast way:

Shell "C:\Program Files (x86)\Notepad++\notepad++.exe -notabbar", vbMaximizedFocus

or to use your code:

public sub demo()
  Shell "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\TF.exe status $/MyProject/Documents /recursive"
end sub

By the way - usually there is, and should be, a warning, when executing files through hyperlinks. So if you wan't to use HYPERLINK because of "don't like warnings", you got them there too ;)

On the other hand - the VBA solution can avoid warnings, if you sign your Workbook with a trusted signature or use it in a folder, wich is setup as trusted for macros.