Monday, February 15, 2010

Create New document link in ListView Web part

Hi All,

We all know that in document library we have an option where in we can click on New menu item and click on document and we are presented with nice blank document to type in. Same way we can have our templates defined and can be made available in the new menu.

However ever wondered when you place list view web part of that document library on any page, you get an option of “Add new document” but when you click on that link, it takes you to a page where you can upload the document that you’ve created. See below screenshot.



Now this is not what we want according to Create New document means. We should be presented with blank document, which New menu does.

So we need to do some magic here and creates some more link under list view web part. We should ultimately give a link by which use is presented with blank document, not the upload page option.

So here is a trick to do this.

Go to modify this web part and in Toolbar Type select No toolbar. This will turn off the Add New document link.

However for now, select Full Toobar and go to source view of the page and search for “createNewDocumentWithProgID”. For me it was something like this. All you have to search for is from createNewDocumentWithProgID to false.

createNewDocumentWithProgID('https:\u002f\u002fxxxxxxxxxxxx\u002fteams\u002fpds1\u002fpss\u002fxxxxxxxx\u002fShared Documents\u002fForms\u002ftemplate.doc', 'https:\u002f\u002fintranet.eclipsnet.com\u002fteams\u002fpds1\u002fpss\u002fxxxxxxt\u002fShared Documents', 'SharePoint.OpenDocuments', false)

Now turn off the toolbar (Select No toolbar) and add content editor web part below the document library list view web part. Click on open toolpane, click on Crome Type as None. Click on Source editor and then add the following content.

<IMG alt="" src=" /_layouts/images/rect.gif">&nbsp;<A onclick="XYZ”;return false;" href="#">Create a New document</A>

Replace XYZ with the searched text for createNewDocumentWithProgID till false and there you go. Check for yourself. This is a great fun.

8 comments:

Anonymous said...

great info man,

How you guys find such things?

Thanks.

Anonymous said...

This looks interesting.
Tried it, but was informed that the link which I just inserted was removed - I guess due to a security issue.

Any hints?

Thanks.

SharePoint Kings said...

Anonymous, where and how you get this msg?

never seend this msg. please describe.

Henry J said...

This is absolutely the bomb. What this will allow me to do is to create a document/forms template library and just create links to the each template. You can create multiple content types in the library and link each content type to a its own template and use your tip to launch the right template. ONce you create additional content types, they will show up in view source. Just copy and paste the cade as instructed in this post.

Anonymous said...

Used a combination of your page and also:

http://erikswenson.blogspot.com/2010_09_01_archive.html

To turn off the "Add document" or "Add new item" button in Sharepoint Designer, force List View Design Options to be "None" by temporarily setting to "Full Toolbar" then changing it back to "None".

SharePoint Kings said...

@Anonymous,

Thanks for sharing.

Pooja said...

Thanks for the article. But unfortunately I could not find the function that you said we need to search in the code. I resolved mine from the link http://support.microsoft.com/kb/2639050

Its quite simple.
P

SharePoint Kings said...

Hi pooja,

Thanks a lot for sharing.




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com