Need a link to create a new document from an Office template?
Posted: 2012-02-04 Filed under: Document management, jQuery, Templates | Tags: jQuery, New document, Office template, SharePoint 2 CommentsHi everyone!
I found this blog post the other day and you can’t imagine the thrill I felt đ
This is something I have wanted to be able to do so many times and didn’t know how to, now I do and I want you to do as well.
As you can see (and read in the blog post) the saveLocation is set from where the template is located. I did a little change to route the save location to a place I decided. I also added a little change to wait until the page is loaded before the function is executed, always a good thing to do.
This is the original code:
<script type="text/javascript" src="/_layouts/jquery.min.js"></script> <script type="text/javascript"> $( function () { $("a[href$='.dot'], a[href$='.dotx'], a[href$='.xlt'], a[href$='.xltx']").attr("onclick", "").click( function () { saveLocation = $(this).attr("href").split("/").slice(0, -2).join("/") createNewDocumentWithProgID(window.location.protocol + '//' + window.location.host + $(this).attr("href"), window.location.protocol + '//' + window.location.host + saveLocation, 'SharePoint.OpenDocuments', false) return false }) }) </script>
and this is my modified one with a hard coded save location:
<script type="text/javascript" src="/Style%20Library/Scripts/jquery-1.4.4.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("a[href$='.dot'], a[href$='.dotx'], a[href$='.xlt'], a[href$='.xltx']").attr("onclick", "").click( function () { createNewDocumentWithProgID(window.location.protocol + '//' + window.location.host + $(this).attr("href"), makeAbsUrl('http://MyIntranet/sitename/sitename/librar%20name'), 'SharePoint.OpenDocuments', false) return false }) }) </script>
Here is another one that prompts to save the document in the logged in users local Document library.
<script type="text/javascript"> $(document).ready(function(){ $("a[href$='.dot'], a[href$='.dotx'], a[href$='.xlt'], a[href$='.xltx']").attr("onclick", "").click( function () { createNewDocumentWithProgID(window.location.protocol + '//' + window.location.host + $(this).attr("href"),'C:\Users\{login}\Documents' , 'SharePoint.OpenDocuments', false) return false }) }) </script>
As always when we are working with jQuery you have to make sure that you reference the location of that .js-file
CU
/Niax
Version and ID in printed document
Posted: 2011-11-10 Filed under: Document management | Tags: ID, Policy, QuickParts, SharePoint, Version Leave a commentAs you probably already know itâs possible to add Quick Parts in Word to add metadata from custom columns in your header/footer.
But getting Version or ID in the header/footer is a whole other bargain.
Itâs really important to get this information inside the document, so that itâs possible to see on a printed copy, what version it is compared to the latest version in SharePoint.
So how should we accomplish this?
â˘Â Make sure you have a document with a header section.
â˘Â Create a Content type and add this document as the template.
â˘Â Navigate to a document library and activate Versioning and the possibility to handle Content types.
â˘Â Add your Content type to the library.
â˘Â Navigate to the settings for the library and then the settings for the Content type. Click on âInformation management policy settingsâ.
â˘Â Check âEnable Labelsâ and add: {Version}nDok.ID: {ID} in âLabel formatâ. Make changes regarding the style as it fits you.
â˘Â In advanced settings for the Content type, choose to edit the template.
â˘Â Put the cursor where you want to have the Version and ID added.
â˘Â Click on Insert, Quick Parts, Document property and Label.
â˘Â Save, click Ok and try it out.
The first time you open up the document it looks a little bit strange because there is no version yet, but donât worry, save and open the document again and behold the version.
/Niax