Okay, so in SharePoint we’ve got document libraries. In them (provided we have the rights) we can go to the toolbar and click ‘New’, select a document type, and be shown a template document to start filling in. That’s pretty nice.
Often, though, we might want to surface those documents (or some of those documents) on a Page – either a Publishing Page or a Normal Page. We can do that with the ListView Web Part:
As you can see, it can show an ‘Add new document’ link. We could also get it to show a toolbar very similar to the one in the List itself, or we can configure it to show nothing at all!
However, the ‘Add New Document’ link and the toolbar have quite different functionality. The ‘New’ button on the toolbar opens a new document, and lets you fill in the template, whereas the ‘Add new Document’ link simply takes you to the file upload page – so you don’t get a nice blank templated document to fill in.
That’s a little unfortunate. We’d a customer who didn’t want to show all the toolbar on their home page, but wanted to use a specific document template for when users tried to create a document. So, in short, the functionality of the toolbar menus – but in a link at the bottom of the ListView, like this:
So, how did I do this? Well, I started by turned off ‘Toolbar’ and ‘Summary toolbar’, so there was no way to add a new document with the ListView web part. Then, below it, I added a Content Editor web part and put the HTML code in there.
But how did I actually make this work? Well, I turned on the full toolbar, and then viewed the page source. I found the MenuItem itself – if you want to do this for yourself, search for “zz11_New0” or “createNewDocumentWithProgID”
createNewDocumentWithProgID('http:u002fu002fvm-moss2007u002fMod Propsu002fFormsu002fMod Propsu002fModPropTemplate.xlsx', 'http:u002fu002fvm-moss2007u002fMod Props', 'SharePoint.OpenDocuments', false)
Next, I turned off the toolbar for the Mod Props web part, and I then added my new content editor web part. I switched to HTML mode, and typed in:
<IMG alt="" src=" /_layouts/images/rect.gif"> <A onclick="XXXX;return false;" href="#">Create new Mod Prop</A>
<IMG alt="" src="/_layouts/images/rect.gif"> <A onclick="createNewDocumentWithProgID('http:u002fu002fvm-moss2007u002fMod Propsu002fFormsu002fMod Propsu002fModPropTemplate.xlsx', 'http:u002fu002fvm-moss2007u002fMod Props', 'SharePoint.OpenDocuments', false);return false;" href="#">Create new Mod Prop</A>