0

I have a view form in SharePoint 2013, and I am trying to create a button that will export the form into a MS word document.

So really I am trying save a item in my SharePoint view form to a word file. Is that possible? enter image description here

  • Based on my experience Out of the box not possible. You need to do it via Custom Coding. – Amal Hashim Jan 26 '15 at 15:14
  • can you provide more details how I can achieve, custom coding is not my thing but with good details I can manage it – Matt Ludwig Jan 26 '15 at 15:17
  • any one have suggestion? – Matt Ludwig Jan 26 '15 at 18:25
1

Yes, this is quite do-able, and you can do it out of the box. No custom code required - use SharePoint Designer 2013 ONLY.

I just implemented something like this.

What you can do is, using SharePoint Designer 2013, create a Workflow that uses the data from a List to create an item in a Library. You create a document library with the same fields as the list, and the workflow creates the item in the document library and passes over the values of the fields. The document template for the library will be customized, and you can easily insert the SharePoint list fields into the document using Quick Parts. Finally, set up a Custom Action that runs the workflow on a selected item.

The basic process is : Create Site Columns; Create Content Types; Create List and Library; Set up Document Template; Create Workflow.

There are a few "gotchas" though, so I will walk you through it:

Steps:

  1. Create the columns for the data as site columns
  2. Create a list item content type and a document content type and add the columns to each (its easiest to go to the Administration Web Page for the content type and click "Add Site Columns")
  3. Create a list and a library for each of the content types - enable custom content types and associate each with its respective content type.
  4. Set up the Document Library

    a. Make your custom content type the default, and remove the old "document" content type.

    b. Use the "Edit Document Template" button (on the ribbon) for the Library, open it, and then save it back to the site as a .docx file (not a .dotx file). You MUST save the template as a .docx file.

    c. Set the Document Template URL for the Library to the .docx file

You can now open you document template and add in the fields for the columns by going Insert -> Quick Part -> Document Property

  1. Create your workflow. In SharePoint Designer Hit the New button on the Workflows section of your LIST (not the library)

    a. Create a new SHAREPOINT 2010 Workflow (NOT 2013). It MUST be a 2010 Workflow.

    b. In the workflow, set up an Action to Create New List Item in your Document Library. You will then be prompted to pass over fields and values.

    c. You MUST pass over the "Content Type ID" field and set the value to your custom content type

    d. You MUST set the "Path and Name (*)" variable to something like [%Current Item:Title%].docx

    e. Now you can go to the Workflow Settings and set the Workflow to run automatically whenever you create a new item on the list, or go to the list and set up a Custom Action to run the workflow.

  • Thank you for this jRause, I have a few questions... When adding a list I created on for "Customer" in the "custom Columns group" now what do I do with the column? also for step 4 what do you mean remove old document content type, and how do I access "edit document Template" thank you for you help. – Matt Ludwig Jan 27 '15 at 15:39
  • Create the columns as site columns, then create a content type and add the site columns to the content type. Then create a library, and in the library settings, enable content type management, add the new content type, set it as default content type for the library, and then delete the old default content type (Document). The "Edit Document Template" button is on the ribbon when you go to the Library Settings page. You are doing this all in SharePoint Designer 2013 by the way. – temporary_name Jan 27 '15 at 19:30
  • As soon as you click the "Edit Document Template" Word will fire up with a blank document template. Then you want to go "Save As", select the path where the template came from, but change the file type to "Word Document". Save it there beside the "template.dotx" file but this time its called "template.docx". Close Word. Now in the Library settings, change the file extension in the URL for the document template to be "template.docx". Now when you click the Edit Document Template button in SharePoint Designer, it will open the docx file. – temporary_name Jan 27 '15 at 19:37
  • Do you have a email account or gtalk so we can talk better it seems like I am stuck I really appreciate it – Matt Ludwig Jan 27 '15 at 19:58
0

There are couple of ways to do this.

  1. Create a Word Template file which resembles the exact look and feel of the view form. Then populate it using Mirosoft Word Interop or using Open XML SDK
  2. Create the word document using code (Here all the style etc you should create using code)

https://vivekcek.wordpress.com/2012/08/25/create-a-word-document-from-a-template-using-c-mail-merge/

https://stackoverflow.com/questions/27188906/asp-net-c-creating-word-document-from-template

  • That is the reason I said this is not possible Out of the box and require custom coding. – Amal Hashim Jan 26 '15 at 19:36
  • On print button click you can use JavaScript to hide unwanted screen elements. and then invoke window.print(). – Amal Hashim Jan 26 '15 at 19:40
  • <input onclick="window.print();return" type="button" value="Print Form"/> That is my print button, where would I put the javascript and is there a pre-created one for what I am trying to do? – Matt Ludwig Jan 26 '15 at 19:46
  • Nope. Create a new function. function PrintForm(){$('#elementId').hide();window.print();} .. Remove elementId with the id of the html element. – Amal Hashim Jan 26 '15 at 19:47
  • Please see above image, what would I put in the ID if I don't want to print the entire top green section? – Matt Ludwig Jan 26 '15 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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