Need a link to create a new document from an Office template?

Hi 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

As 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