Quick tip: Add a “Create New Document” link on a page outside a document library in SP2007

If you want to display a link that allows you to create new items in a SharePoint 2007 document/form library, you can easily do that in a Content Query web part. Just do the following:

1. Navigate to the library where you want to be able to create new items.
2. Open up the source code of the page and search for the string “onclick=”createNewDocumentWithProgID(‘”
3. That’s the “New Document” link. Steal it! Copy everything that pertains to the onclick event.
4. Navigate to the page where you want to add the new link.
5. Add a Content Query web part
6. Edit the “Source Code” and add the following:

<a onclick=”THE ONCLICK EVENT YOU NICKED FROM THE LIBRARY PAGE SOURCE CODE”  href=”#”>Some Display Text</a>

That should create a link for you. The onclick event is on your master page so don’t go looking for it in order to add a javascript. It’s there already. The ‘href=”#”‘ part is there to provide a uniform experience for the user. Without it, the display text will appear and clicking on it will still navigate to the new item creation, BUT the little hand shaped cursor will not appear when you hover over the link. The href bit will tell the browser that there is a link there, the cursor will change to a little hand and clicking on the link will allow the user to create a new document in the relevant library.

MGR: the Intelogist

About MGR: the Intelogist

SharePoint Server developer, turned Sitefinity developer, turned Angular developer, turned SharePoint Online consultant, turned Unily consultant, turned O365 consultant... Never a dull moment!

2 thoughts on “Quick tip: Add a “Create New Document” link on a page outside a document library in SP2007

  1. Ruby

    I’d like to thank you for the efforts you’ve put in
    penning this website.

    • MGR

      Ah, thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

This site uses Akismet to reduce spam. Learn how your comment data is processed.