Paul Liebrand’s Weblog

Welcome to my blog mainly about SharePoint

Adding Office File Types to all Document Libraries New Menu without Content Types

One of the questions I am asked the most from my end-users when using SharePoint is "Why can’t I select new Word, Excel, and PowerPoint from the new drop down on all my document libraries?"

With the introduction of Content Types in Windows SharePoint Services (WSS 3.0 solved this problem by creating a content type called Word Document, Excel Document, and PowerPoint Document. They would then apply those content types to all the document libraries on their site.

 ContentTypes

While WSS 3.0 added this flexibility and my end-users were happy I noticed an issue with this implementation. When users were saving documents to SharePoint via Windows Explorer or the multiple file upload it selects the default content type (Word Document).

ContentTypeIssue

As you can see, this starts to cause an issue because all different file types start being marked incorrectly. Of course, the users can go back and change this to make it work but realistically this is not going to happen.

At the end of the day, content types should be used as they were intended (Memos, Invoices, etc) and simply creating one for Word, Excel, and PowerPoint was a "hack" to solve an end-user experience problem.

The Solution

I created a SharePoint feature (Source and Solution links available below) that basically adds Word, Excel, and PowerPoint to the new drop down menu of all document libraries within a site collection. This implementation does not make use of Content Types and allows users to quickly create a new document of these types in any document library. The beauty of this implementation is that if a document library does have content types, such as an invoice, when the user saves a document the first time (after selecting Word, Excel, or PowerPoint) it will prompt them to select the appropriate content type. Since my new menu items are not implemented as content types they are not visible from within the Content Type selector.

The following is a series of screen captures that demonstrate my implementation of Office File Types.

Once the feature is activated via the Site Collection Features, all document libraries will now look like this:

OfficeFileTypes

As you can see, you can still have content types and the Office File Types appear at the bottom.

When the Office application launches and you click Save and provide a filename, it will now ask you to select the appropriate content type:

ChooseType

The document library will refresh and everything appears as it should be:

StoredDocuments

I personally think this just creates a better end-user experience especially for those people who work a lot with Office documents in SharePoint.

Known Limitations

Right now the Office File Types feature does not recognize the folders you drill into. This was really put together as a proof of concept and will most likely be enhanced overtime.

Source and Solution

Note: No assembly was developed to get this to work. The feature basically just adds some custom actions to the document library list type and all the magic happens through JavaScript.

http://www.codeplex.com/OfficeFileTypes

I hope you find this useful.

[Update – 5/15/2008]

Just incase anybody needed this information — Here are the installation instructions:

 

stsadm -o addsolution -filename OfficeFileTypes.wsp

stsadm -o deploysolution -name OfficeFileTypes.wsp -url <url of your site> -immediate -allowgacdeployment

 

Once the solution has been deployed, you just navigate to the site collection and activate the Office File Types feature.

[Update – 7/7/2008]

I removed the rights attribute from the OfficeFileTypes.xml because SharePoint completely ignores this if you have unique permissions set on the document library itself (thanks Marco). In this particular case, since I am added the Office file types to the new menu which is only visible to people who can add content, the rights was not necessary. However, this seems to be a bigger issue if you wanted to add something to the actions menu, or settings menu.

Both source and WSP files have been updated.

[Update – 7/8/2008]

Even though the new solution works around the issue mentioned above it has introduced another scenario. Because I removed the AddListItems right the New menu now shows up with the Office File Types for users who have read-only rights.

I have started a thread on the MSDN SharePoint Development forums (http://forums.microsoft.com/forums/ShowPost.aspx?PostID=3590618&SiteID=1) so hopefully Microsoft can offer some guidance to this issue. I personally believe this is a bug, or CustomAction implementation issue that will have to be resolved by Microsoft so that I can use the Rights attribute of CustomAction again.

[Update – 7/8/2008 – Part II]

Due to the issues I ran into using the Rights attribute of the feature I completely re-worked the whole solution. Now it uses code to figure out if they have the appropriate permissions or not based on the library and folder they are in.

Both the source and WSP file has been updated.

[Update – 7/11/2008]

The solution has been updated to hide and show the specific Office Types depending on what the document content type has been setup for. For example, if the default document content type is an XLS file, the Excel Office File type will not show on the new drop down. The feature also now supports localization, so you simply need to copy the officefiletypes.resx file and create it for your appropriate language and you are good to go.

[Update – 7/24/2008]

I moved this project to CodePlex at http://www.codeplex.com/OfficeFileTypes for those interested in the Source and Release.

May 14, 2008 - Posted by | SharePoint

46 Comments »

  1. Hi,

    I’m having the same problem as you when working with dynamic menu’s.

    I’ve also developed a control to render my menu items dynamicly and this one works everywhere I put it, except under NewMenu.

    Under NewMenu I can add labels and other controls, just not MenuItemTemplates.

    I’ve read you had the same problem and I wondered if you had found a solution now.

    Greetings,

    Pascal

    Comment by Pascal Van Vlaenderen | June 4, 2008 | Reply

  2. Pascal,

    Unfortunately not. Before I came up with the JavaScript solution I tried many different methods to attempt to get the CustomActions to appear on the NewMenu and nothing worked.

    Paul Liebrand

    Comment by liebrand | June 4, 2008 | Reply

  3. To bad 🙂

    Thanks for your fast reaction !!!

    Comment by Pascal Van Vlaenderen | June 4, 2008 | Reply

  4. Hey,

    After 2 days of searching, I found a way to make it work 🙂

    If you are still interessed, I’ll send you the code next week

    Comment by Pascal Van Vlaenderen | June 6, 2008 | Reply

  5. Please do… I am interested.

    Comment by liebrand | June 6, 2008 | Reply

  6. Here is the link of the blog item I made about it:

    http://docs.teamlink.be/collaborate/PublicBlog/Lists/Posts/Post.aspx?ID=3

    Comment by Pascal Van Vlaenderen | June 7, 2008 | Reply

  7. Okay,

    I’ve worked my solution out a bit and now I’m having the following problems.

    I used a document library to store document templates and then this feature to show them.

    2 problems arise now:
    1. the document properties of the first document library are shown in word
    2. the save location, doesn’t save well.

    Do you have any solution to this ?

    I’ve noticed you use javascript fuctions in your feature. I suspect it places a http://url to use as savelocation, does it ?

    Thanks

    Pascal

    Comment by Pascal Van Vlaenderen | June 9, 2008 | Reply

  8. Pascal,

    Yes — my solution does make use of JavaScript to get the context of the list and then call the createNewDocumentWithProgID function. The second parameter of this function is the Save Location you are passing to the Office Application. For example,

    createNewDocumentWithProgID(‘Excel.Sheet.8′,’http://site/library’,’SharePoint.OpenDocuments’, false)

    This will create a blank Excel spreadsheet and set the save location to http://site/library.

    Comment by liebrand | June 10, 2008 | Reply

  9. Yeah,

    Figured this out 🙂

    Got everything to work now.

    I use a custom list to organise my templates (category etc)
    and a document library to store the templates and if I need a column for all the templates i make one in that library.

    the saving problem was related to windows 2008.

    Thanks 🙂

    Comment by Pascal Van Vlaenderen | June 13, 2008 | Reply

  10. Hi,

    Great solution!! Wish I’d found this solution a while back…
    But, after implementing it on our test environment I’m experiencing a strange problem.
    When a specific test user tries to test the solution the office file types don’t show up in the new menu.
    Another test user (with the same rights on the doclib) it works as expected.

    Any clues on where to start looking?

    Comment by Marco | July 1, 2008 | Reply

  11. Marco,

    In the “OfficeFileTypes.xml” you will see that each menu item has an attribute called “Rights” I would try remove that from the file, redeploy and reactivate the feature and then see if it shows up for the other user.

    This “rights” attribute basically tells SharePoint to only render the menu if the user has “Add List Items” rights. If both your users have the exact same permission, I would at least start here.

    This will basically render the menu regardless of user permissions.

    I’ll attempt to see if I can duplicate this problem and report back if I find anything.

    Comment by liebrand | July 1, 2008 | Reply

  12. Hi Liebrand,

    I’ve removed the rights attribute. It shows up for the specific user. Another test-account with only read rights it shows up as well. So the rights attribute works well.

    The strange thing is after re-deploying the original officefiletypes.xml the 3 entries aren’t visible. Just the New Folder and New Document (contenttype).

    I think i’ve narrowed it down to the following:
    A user must be a member of the site members group. When a user is given modify rights on the documentlibrary self it doesn’t work.
    Does this make sense to you?

    Comment by Marco | July 7, 2008 | Reply

  13. Okay,

    This is the situation:

    3 test users
    test_1: member of the site members group
    test_2: read right on the doclib
    test_3: contribute right on the doclib.

    test_1 user sees the 3 officefiletypes + new folder/document
    test_2 user sees nothing
    test_3 user sees only the new folder/document option

    Could this be a bug in SharePoint?

    HTH,

    Marco

    Comment by Marco | July 7, 2008 | Reply

  14. I have read through the SDK and there is no indication of such limitation. However, I was able to duplicate the issue using the permissions you outlined here. I’ll let into some more but it appears it might be a bug.

    Comment by liebrand | July 7, 2008 | Reply

  15. Since the Office File Types are being added to the New Menu which is not visible unless you have the rights to add something to the list, I went ahead and updated my solution file it remove the “rights” attribute. Download the new one and deploy it — you should be good to go.

    Comment by liebrand | July 7, 2008 | Reply

  16. Hi Liebrand,

    When removing the rights attribute people with read rights on the doclib see the officefiletypes (and the new button).
    So this is not an option for me.

    Probably not the way to go.

    Let me know if you find another solution.

    Thanks

    Comment by Marco | July 8, 2008 | Reply

  17. Odd. When my users do not have the ability to add content they “new” button is not visible. Is the Office File types the only thing listed there, or do you also have “New Folder” and “New Document”.

    What is the version of SharePoint you are running?

    Comment by liebrand | July 8, 2008 | Reply

  18. Hi, only the Office File Types are shown.
    MOSS 3.0 SP1 (12.0.0.6039).

    I’ve mentioned this situation in comment#12.

    Comment by Marco | July 9, 2008 | Reply

  19. Marco,

    Please install the new WSP file using the link above in your environment. This should resolve the issue you outlined in comment#12. See my comment#15. I fixed it.

    Comment by liebrand | July 9, 2008 | Reply

  20. Hi Liebrand,

    The issue that a read only user now has a new button with only the Office File Types still exists.

    Comment by Marco | July 9, 2008 | Reply

  21. Marco,

    Try again — the solution has been completely redone and it should solve that problem (hopefully).

    Comment by liebrand | July 9, 2008 | Reply

  22. Hi Paul,

    The last version of the solution works!
    I’ve tested it tonight. And it seems to work fine!

    Do you have plans to make it multilingual?

    Thanks for spending your time in fixing the solution.

    Regards,

    Marco

    Comment by Marco | July 10, 2008 | Reply

  23. […] create new Office documents without the use of content types, or selecting a template up front (see Adding Office File Types to all Document Libraries New Menu without Content Types for more […]

    Pingback by SharePoint Feature or Enhancement Requests « Paul Liebrand’s Weblog | July 22, 2008 | Reply

  24. Hi Guys;
    ı have complete the installation with
    stsadm -o addsolution -filename OfficeFileTypes.wsp
    stsadm -o deploysolution -name OffceFileTypes.wsp -allcontenturls -allowgacdeployment -immediate

    there commands but new file types didnt appear ??

    Did I miss something ?

    Comment by Guney | November 19, 2008 | Reply

  25. Guney,

    Make sure you activate the feature via the Site Collection Features menu. Once activated, you should see the Office File Types appear on your New Menu.

    Thanks,

    Paul

    Comment by liebrand | November 19, 2008 | Reply

  26. Hi,
    This is a great solution Paul. I have upgraded sites from SPS2003 to MOSS2007, and activated your solution. I find that the file types are not displaying in the ‘new’ menu for me on upgraded document libraries, but are appearing in ones that I newly create in the same site. I am the farm admin, so it shouldnt be a permissions issue. any ideas why this is happening?
    Chris

    Comment by Chris | February 20, 2009 | Reply

  27. Chris,

    The only thing I can think that is causing this issue is if the upgraded document libraries do not have the “101” template Id. I recommend the following:

    1. Download SharePoint Manager 2007 (http://www.codeplex.com/spm)

    2. Navigate to one of the document libraries that are NOT working and check the “BaseTemplate” and “BaseType” fields. These should be “DocumentLibrary”.

    3. If it does say document library, check the PropertiesXml and see what the number is for ServerTemplate. This should read “101”.

    Please report back your findings.

    Thanks,

    Paul

    Comment by liebrand | February 20, 2009 | Reply

  28. BaseTemplate is empty.
    BaseType is DocumentLibrary.
    The server template says 165. I clearly not count on the value to be 101! Suggestions?

    Comment by Chris | February 20, 2009 | Reply

  29. Chris,

    The only thing I can initially think to try is the following.

    1. De-activate the OfficeFileTypes feature.
    2. Navigate to the 12 hive / Template / Features / OfficeFileTypes folder.
    3. Open the OfficeFileTypes.xml file and add another section that is exactly the same as the one that is there. The only difference is change 101 to 165.

    You would now have two custom actions — one that connects to regular WSS 3.0 document libraries, and one that connects to WSS 3.0 upgraded from WSS 2.0 document libraries.

    4. Re-activate the feature

    Thanks,

    Paul

    Comment by liebrand | February 21, 2009 | Reply

  30. I haven’t had any success. So I decided to just replace 101 with 165 just to enable on th old document libraries only- the SP error page displays. I also restarted iis just to be sure the xml files are re-cached. Paul, I like this solution if we can get it to work with multiple registration IDs. please email me: chris.jenkins@gnb.ca

    Comment by Chris | February 24, 2009 | Reply

    • I’ll see what I can find out and get back to you.

      Paul Liebrand

      Comment by liebrand | February 24, 2009 | Reply

  31. Thanks Paul,
    SharePoint Manager does not let me fill in the blank baseTemplate, nor will it allow me to change the ServerTemplate in SchemaXML or PropertiesXML. This issue is a result of upgrading a custom 2003 STS, unfortunately I have to live with it.

    Comment by Chris | February 24, 2009 | Reply

  32. Hi Paul,
    Any luck fixing that error when I change the server template value? Is there anything I can provide you to help (such as the STS)? Again, great solution, we’d love to use it.

    Comment by Chris | March 4, 2009 | Reply

    • Chris,

      I am still working on building out my WSS 2.0 environment so I can insure there is no abnormalities with the upgrade to WSS 3.0 and templates (which I cannot image there will be). Should have some feed back for you any day now.

      Thank you for your patience.

      Comment by liebrand | March 4, 2009 | Reply

    • It probably will not hurt to get your STS (if there is nothing confidential about it). Send it to mailer@imaxa.com.

      Comment by liebrand | March 4, 2009 | Reply

  33. Great solution. I just wanted to customize the code so that it uses a custom document template when the application launches. I want to implement this by modifying the clientonclickscript, but I’m not sure how to debug this. How do I go about debugging this code?

    Comment by sherry | March 18, 2009 | Reply

    • Sherry,

      The way I debugged the code when working on it was to attach to the browser session using Visual Studio and the set breakpoints in the javascript code.

      Paul Liebrand

      Comment by liebrand | March 18, 2009 | Reply

  34. Hey Paul,
    Great little addition, but where do I go and what files do I need to change to localise this? ie, to Swedish, French, German, whatever…

    Thanks

    Comment by Andy | June 1, 2009 | Reply

    • I responded on Codeplex — but I’ll put the same response here too. After deploying the solution, it would put the .resx files under the 12 hive / resources folder. For example, officefiletypes.en-US.resx and officefiletypes.resx are the two that are supplied by default.

      Comment by liebrand | June 1, 2009 | Reply

  35. Hi Paul!

    Great solution to a very common issue. End-users like it very much. I have to friendly comments/suggestions:

    1. I found that if I changed the default document template for an xls file, I lost the button for the new Word Document, probably because the Regex finds a match on the document library URL /Docs/Forms/Template.xls. Perhaps performing the match on only the file extension would resolve the issue.
    2. I created a custom list template that does not use the default document content type and it does not work. If I may, I suggest to get the current folder’s default content type instead (CurrentFolder.ContentTypeOrder[0]).

    Thanks again, that is great work.

    Comment by Nic | September 2, 2009 | Reply

    • Nick,

      Thanks for the feedback. I’ll plan on looking at this again soon and get these issues resolved.

      Paul Liebrand

      Comment by Paul Liebrand | September 15, 2009 | Reply

  36. Hello,

    I’m getting an error while trying to open a library (after office file types activation), all the stsadm commands were successful. Can it be language issue? (MOSS 2007 Polish)

    Thanks.

    Comment by Nick | September 29, 2009 | Reply

  37. i did check the logs but thers a lot of stuff, shall i paste it here or email you

    thanks for quick replay:)

    regards

    Comment by Nick | September 30, 2009 | Reply

  38. We stumbled over here by a different web address and
    thought I might heck things out. I like what I see so noww i’m followng you.
    Look forward to looking at yoyr web page repeatedly.

    Comment by tee zum abnehmen | June 10, 2018 | Reply


Leave a reply to liebrand Cancel reply