Home › Forums › vLooup for SharePoint › Use SP details for word doc
- This topic has 5 replies, 2 voices, and was last updated 3 years, 10 months ago by Alexander Bautz.
-
AuthorPosts
-
-
February 10, 2021 at 22:48 #32767
Hi Alex,
I have a SP 2013 form which my users need to fill out some information in a word doc. Is there a way to take the info from SP columns and plug into a word doc? I am already having the form open the word doc through another solution of yours. Thanks!
-
February 11, 2021 at 00:03 #32769
Hi,
Yes, you can use quick parts – Google it and you find for example this page: https://tracyvanderschyff.com/2015/11/17/the-lighter-side-of-microsoft-24-quick-parts-in-word-with-sharepoint/Alexander
-
February 11, 2021 at 17:19 #32771
Hi Alex,
Thanks for the info on quick parts. I looked into this and tested, but unless I am not fully comprehending this function I don’t think it will work for me.
1) I am using your code for opening a word file and it can’t use the form templates
2) I’d like to have my users fill out share point custom list form and when needed open the word doc and pre-fill certain info from the SP form to word. Quick parts seems to work the opposite (fill out word doc and save details to doc library fields)
Any possible other solutions? Any further help is appreciated!
-
February 11, 2021 at 17:42 #32773
The quick parts work both ways, but the SharePoint form you fill them into must be the properties-form for an existing file – if you do, they will show when you open the document.
Not sure exactly what you are trying to do, but if the document exists you can use custom code to write the properties to the documents properties before opening it.
If this document have been created from a template that has the quick parts set up (for example in the document header) – your properties will now show in the document.
Alexander
-
February 11, 2021 at 17:54 #32775
Could you give an example of custom code and how that would work?
Basically trying to get fields to generate from sharepoint or word like Name/Address/etc
The goal is to prevent duplication efforts for the end user when needing to fill out the word doc.
The word doc is setup in a table format if that makes a difference.
-
February 11, 2021 at 18:55 #32777
You can try this – I have written it freehand and have not tested it so it might need some more tweaking:
// Find the document ID var doc = spjs.utility.queryItems({ "listName": "YOUR_DOC_LIB_DISPLAY_NAME_OR_GUID", "query": "<Where><Eq><FieldRef Name='FileLeafRef' /><Value Type='Text'>The_document_name.docx</Value></Eq></Where>", "viewFields": ["ID"] }); if (doc.count > 0) { // Found the document - update the metadata var res = spjs.utility.updateItem({ "listName": "YOUR_DOC_LIB_DISPLAY_NAME_OR_GUID", "id": doc.items[0].ID, "data": { "Title": "The value in the title field", "Another_field": "The value" } }); if (res.success) { // Item updated } else { alert(res.errorText); } }
Replace YOUR_DOC_LIB_DISPLAY_NAME_OR_GUID, The_document_name.docx and the field internal names and values in the data parameter of the spjs.utility.updateItem function call.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.