2

I want to launch a doc file in my C:// once a is clicked in my html page

Below my code

<a href="C://mytestfile.doc">Click Me To launch the DOC FILE</a>

unformtunatly, what I'm getting is the "mytestfile.doc" downlowded and not opened in chrome

2
  • Didn't you mean "launch" ? Commented Nov 7, 2018 at 15:54
  • 2
    Lunchtime!!! You will need href="file:///<filePath>" Commented Nov 7, 2018 at 15:56

1 Answer 1

2

You can enter a file URL like file:///C:/path/to/file.txt but the behaviour would change depending on where that's pointing to:

  • If it's a directory, it will show its content in Chrome.
  • If it's a know media type (images, audio, video, pdf, ...) it will play/display in Chrome in the usual way.
  • If it's an unknown media type, like a Word document, it will just trigger a download.

If the file you want to open is not in the local file system but hosted somewhere, you can should check the Office URI Schemes documentation. You would end up with something like this:

ms-word:ofe|u|http://website.com/document.docx

The full schema is:

< scheme-name >:< command-name >"|"< command-argument-descriptor > "|"< command-argument >

The first part is the scheme name (protocol), which is specific for each Office product:

  • ms-word
  • ms-powerpoint
  • ms-excel
  • ms-visio
  • ms-access
  • ms-project
  • ms-publisher
  • ms-spd
  • ms-infopath

The second part is the command name and its arguments (pars for argument descriptor + argument value), all separated with |:

  • ofv|u| (open for view), followed by the URI to open in view mode.
  • ofe|u| (open for edit), followed by the URI to open in edit mode.
  • nft|u| (new document from template), followed by the URI to the template.

    Optionally, you can add a second argument, s, with the URI of the folder where you want to save it, so it will end up looking like this:

    ms-word:nft|u|http://website.com/template.dotx|s|https://website/docs
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.