Launch Document Content Type Templates From Any Web Page with a Link

SharePoint Version

This example was created using SharePoint Enterprise 2010.

Example Overview

This post details how to create a link to a document content type’s template (Word, Excel, PowerPoint, etc.) and place it on a site’s home page (or any web page in the site). I used this solution because I wanted users to have easy access to the template, and, I wanted the template to save back to the library the content type was associated with. Using this method it is possible to avoid having users navigate to the library web page and access the template from the Document tab of the Ribbon using the New Document button.

NOTE: This post does not relate to creating a link or modal pop-up to a list form. This post relates to document content types.

Getting Started – Create a Document Content Type and Document Library

Step Action
1 Create a site content type using Document for the parent type.  Call the content type Project Status Report.
2 I used Microsoft Words Office.com Project status report template as my content type’s template. Save the template file locally, then associate the Project status report template to the content type in its Advanced Settings.
Document Content Type Link - Associate a template with the content type
3 Create a document library and name it ContentType.
4 In the ContentType library enable the use of content types and add the Project Status Report.
5 On the the library web page, the Project Status Report template is available under Library Tools, on the Documents tab, from New Document. Document Content Type Link - the template is available from the new document button

Get the Document Content Type Source Code and Make It Your Own

Step Action
6 Add the ContentType library to the site’s Default.aspx or Home.aspx page.
Document Content Type Link - Add the library to the home page
7 Edit the web part.
Document Content Type Link - Edit the document library
8 Select Show Toolbar and click Ok to save the setting.
Document Content Type Link - In the web part settings select show toolbar
9 The ContentType library now displays with the Toolbar.
Document Content Type Template Link - the library displays with the tool bar and new button
10 View the Source code for the page.
Document Content Type Template Link - View the source code for the content type
11 Select CTRL+F and enter Project Status Report to locate the template information in the code.
Document Content Type Link - CTRL+F to locate the content type onclick code
12 Locate the code beginning with onclick=”CoreInvoke through true, 1)”>.  Copy the code.
Content Type Template Link - Highlight from onclick to true 1
13 Paste the code into Notepad.  Add <a at the beginning of the first line.  At the end of the existing code, input the following link text followed by the closing tag:  Project Status Report</a>.  Leave the text file open.
SharePoint Document Content Type - Copy the onclick code and add additional information
14 Delete the ContentType library from the Default.aspx or Home.aspx page.
Document Content Type Template - Delete the document library
15 Add a Content Editor Web Part to the Default.apx or Home.aspx page.
Content Type Word Template - Add a CEWP
16 Click Click here to add new content then HTML.  In the HTML Source editor, paste the code from the Notepad file.
Content Type Word Template - Update the Content Editor Web Part with the source code
17 The link to the document content type’s template now displays on the site’s landing page.
Content Type Link to Template - the Word template displays as a link
18 Clicking the link will open the template.
Document Content Type Word Link - The content type opens from the link on the web page
19 When a user saves the file, the default save location is the ContentType library.
Word Template Content Type Link - The file's default save as is to the associated library
20 The file saves to the Content Type library.
NOTE:  The user is not directed to the library page, the user stays on the site’s landing page.
Content Type Link - The content type's Word template saves back to the document library

Modifications

Copy the code to a text file and link to it in the Content Editor Web Part to ensure the code is not inadvertently modified.

Document Content Type - Link to code using a text file

For a nicer display, create a button for the link.

Document Content Type Link - Create a button to use as a link to the content type's template.

Advertisements

29 thoughts on “Launch Document Content Type Templates From Any Web Page with a Link

  1. Hi Jenny –

    I am using SharePoint Server 2013. With a few modifications, I was able to create a link. I did notice differences in my back-end code from your example, with the most important difference including 'ms-word' before the last paren. My code also has true in some places where yours had false, and “0” instead of “1”. All of which I chalked up to a difference in our implementation at my company vs. yours.

    I appreciate your clear documentation, and maintaining this resource in the years since you first wrote this instruction. You’ve made my day.

  2. Django says:

    My code in SharePoint 2013 looks like:
    CoreInvoke(‘createNewDocumentWithProgIDEx’,event,’https:\u002f\u002fURL\u002fservice\u002fSITECOLLECTION\u002fRemovableTestSite\u002fApprovalFlow\u002fExcelSheets\u002fForms\u002fAFsheet\u002ftemplate.dotx’, ‘https:\u002f\u002fURL\u002fservice\u002fSITECOLLECTION\u002fRemovableTestSite\u002fApprovalFlow\u002fExcelSheets’, ‘SharePoint.OpenDocuments’, false, ‘ms-word’)

    I can’t get this to work even if I use your format:
    createNewDocumentWithRedirect Test

    Am I missing something very important?

  3. mushi says:

    hey,

    Thanks for this blog and easy to follow. Having issue that my link doesnt work. I have the code and my code matches yours. But when i click on on the link, it registers the click but does nothing. ( i am on sharepoint 2013, so that might be the issue?)

    Any idea?

    Using HTML form webpart and putting code in there.

  4. Anonymous says:

    Excellent article, exactly what I needed for my ECM. I wanted to link to the templates using a promoted list, but can’t get the link to work via the “New Item” mask. Any thoughts how that might work? Thanks

    • Hi there and sorry for the delayed response. Promoted Links lists use the URL field type which only accept http addresses. The only way I can think to use this code and have something interactive like a Promoted Links list is a combo of the code, HTML, and JavaScript. If you figure it out please hop back over and supply a link to your instructions. Thanks!

  5. Hi Jenny,
    The article makes a great read, but I’m having trouble following your steps. Just a thought… Since I’m an instructional designer, you may want to add a bit more detail to each step…even if it seems obvious to you.
    Thanks,
    Mark

    • Hey Anonymous.

      I am guessing you are having issues with step 11 and step 12 if you are asking for the code. Here are a few things you can try to make it easier to get the onClick source code:

      • Have only one content type enabled for the list or library. Look through the comment strand for instructions on working with a library with multiple content types.

      • Make sure your content type, library, and web page are all named differently. The more similarly named content on a page you have, the more you will need to sift through to locate the correct onClick line in the source code.

      • Don’t forget you need to add opening <a and closing tags around the onClick.

      The code is really ugly but a template is below. Your best bet is to find the lines successfully in the source code as I’ve outlined in steps 11 and 12 of my post.

      onclick=”CoreInvoke(‘createNewDocumentWithRedirect2′,event,’YOUR URL HERE’, ‘SHORTENED URL’, ‘SharePoint.OpenDocuments’, false, ‘CREATE NEW ASPX URL HERE?id=YOUR URL HERE’, true, 1)”>YOUR LINK TEXT HERE

      Good luck!

  6. Carlos says:

    This is definitely an easy way to get the complicated link! It wasn’t working for me in 2013 until I replaced the spaces in the URL with %20.

    Thanks!

  7. Kris says:

    Well done. I looked at a few links to get this figured out and yours did the trick. FYI works in SharePoint 2013 as well.

    Cheers.

    Kris

  8. This is great. I have an additional question. I have attached multiple content types with a template to the document library. I would like to beable to create a link/button to each of the templates. For the other templates it uses “onmenuclick” rather than “onclick”. I have tried both, but the link does work (does not create a new document based on the contentype template) Any suggestions?

    • Kevin,

      Modify the library settings so that only a single document content type is visible at a time. With only one document content type set to visible follow the steps starting at step 10 through completion. For each content type take turns setting it to visible and completing steps 1 through completion.

      To configure visibility for a content type: 1) go to your library settings, 2) in the Content Type section, click the Change new button order and default content type link. Then 3) select only a single content type to show at a time.

      Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s