Paul Liebrand's Weblog

Welcome to my blog mainly about SharePoint

Skip to: Content | Sidebar | Footer

Google Search

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

14 May, 2008 (09:34) | SharePoint | By: Liebrand

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.


Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit