0

I want to replicate the behavior of opening a office template file (e.g. .dotx).

The link should allow the user to create a new document with no attachment to a SharePoint library based on a document/template stored in a SharePoint library.

Cheers,

JJ

0

4 Answers 4

4

This was not as easy as i first expected but here is my solution:

This block opens the new document with the designated libray as default savelocation:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
 <body>
  <a href="javascript:;" onclick="CoreInvoke('createNewDocumentWithRedirect2', event, 'http://mysite.local/project/TempLib/template.docx', 'http://mysite.local/project/Doclib', 'SharePoint.OpenDocuments', false, 0, true, 0);"><h2 class="ms-rteElement-H2B">New Document</h2></a>
 </body>
</html>

Leave the savelocation empty and the user will be promptet to select a location manually i.e. the solution I was looking for initially:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
 <body>
  <a href="javascript:;" onclick="CoreInvoke('createNewDocumentWithRedirect2',event, 'http://mysite.local/project/TempLib/template.docx', '', 'SharePoint.OpenDocuments', false, 0, true, 0);"><h2 class="ms-rteElement-H2B">New Document</h2></a>
 </body>
</html>
1
  • In my testing I found that the first 0 argument you have should reference _layouts/15/CreateNewDocument.aspx?id=/path/to/template.docx, the second 0 should be 1 and a final argument ms-word is rquired, as per this MSDS thread. Apr 19, 2017 at 0:10
0

You can force the "download a copy" functionality by forging a link like this:

http://yoursite/_layouts/download.aspx?SourceUrl=url-to-document
3
  • This approach seems to be the suggested solution when googeling but in my setup it won't fly due to access restrictions.
    – Fubzot
    Apr 30, 2014 at 14:15
  • @Fubzot what do you mean? application pages in _layouts folder are accessible to all users. The Download a copy link you see on the ECB menu calls the download.aspx page
    – MdMazzotti
    Apr 30, 2014 at 15:32
  • You are probably right, and I must admit I do not recall the specifics. Regardless I was unable to do it this way and thanks again for your suggestion.
    – Fubzot
    May 1, 2014 at 18:59
0

There is a javascript function which allows this. See answer to this question Sharepoint Site with Excel Sheet Template for Users to create New Sheets

1
  • Thanks for the suggestion however i couldent get createNewDocumentWithProgID to produce the required behavior. However this lead me to stumble upon: createNewDocumentWithRedirect2 wich for my purpose does the trick.
    – Fubzot
    Apr 30, 2014 at 14:19
0

This worked for me.

<a onclick="CoreInvoke('createNewDocumentWithProgIDEx',event,                             
'https://Site/sites/Test/Business%20Memorandums/Forms/template.dotx', 
'https://Site/sites/Test/Business%20Memorandums', 
'SharePoint.OpenDocuments', 
false, 'ms-word')" href="#">New Document</a>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.