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?
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:
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
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.
There are couple of ways to do this.
Mirosoft Word Interopor using
Open XML SDK