How to uninstall MSDAIPP (Web Folders) from Windows 7

We had a Windows 7 workstation that was exhibiting “wonky” behavior when opening SharePoint folders in Office 2010 Word (and explorer in general). When it was supposed to open the save-as dialog to a SharePoint folder, it would instead show the default “My Document” folder. You could still enter a SharePoint url, and it would load correctly, but the initial dialog refused to open SharePoint.

Using Fiddler2 I was able see that the problem computer was using a different WebDAV client than the working workstations from the User-Agent in the requests. The first request is identical:

OPTIONS http://sharepointserver/doclib/ HTTP/1.1
User-Agent: Microsoft Office Protocol Discovery
Host: sharepointserver
Content-Length: 0
Connection: Keep-Alive
Pragma: no-cache

 

But the second request is all kinds of different.

Normal Workstation:

OPTIONS http://sharepointserver/ HTTP/1.1
User-Agent: Microsoft-WebDAV-MiniRedir/6.1.7601
translate: f
Connection: Keep-Alive
Host: sharepointserver

 

Problem Workstation:

OPTIONS http://sharepointserver/ HTTP/1.1
User-Agent:
Microsoft Data Access Internet Publishing Provider Cache Manager
Host: sharepointserver
Content-Length: 0
Connection: Keep-Alive
Pragma: no-cache
Cookie: WSS_KeepSessionAuthenticated={164a5252-50a4-4112-9e22-ae36dfsdddc}

 

The next request gets even weirder:

Continue reading

Adding / Modifying Choices in a SharePoint Choice Field programmatically using the Client Object Model

The SharePoint 2010 Client Object Model isn’t the best documented thing in the world, but it sure does make some tasks a lot easier (without requiring execution on the sharepoint server itself)

I needed to add an option to a dropdown list in a bunch of document libraries. Here’s how:

...
using sp = Microsoft.SharePoint.Client;
...
        private void AddChoicesToField()
        {
            using (sp.ClientContext cxt = new sp.ClientContext("http://sharepointserver"))
            {
                //Basic code to load the list
                sp.Web myWeb = cxt.Site.OpenWeb("http://sharepointserver/sitename");
                cxt.Load(myWeb);
                sp.List myList = myWeb.Lists.GetByTitle("MyListName");
                cxt.Load(myList);
                //The field must be cast to a FieldChoice using context.CastTo
                sp.FieldChoice myField = cxt.CastTo<sp.FieldChoice>(myList.Fields.GetByInternalNameOrTitle("My Field Name"));
                cxt.Load(myField);
                cxt.ExecuteQuery();
                //Copy the choices to a string list
                List<string> OptionList = new List<string>(myField.Choices);
                //Add whatever new values you want to the list
                OptionList.Add("New Value");
                //Convert the list to a string array and assign it to the Choices parameter
                myField.Choices = OptionList.ToArray();
                myField.Update();
                cxt.ExecuteQuery();
            }
        }

Make sure your project has a reference to Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime.

Undocumented behavior of Office 2010 Word Save As dialog with Sharepoint

Here’s another Office 2010 undocumented “feature”.

First a little background regarding required fields in sharepoint:
In Office 2007, in order to attach the Sharepoint properties to a document you had to first Save it into the document library. Word would allow you to save, but the document would remain checked-out to you until you filled in the necessary required properties, and checked it in.

If you were developing a system that automated adding documents to SharePoint, you could not even present the Document Information Panel to the user until the document was already in SharePoint. If the user decided to cancel… you had hanging files.

With Office 2010, Word (and I imagine other apps) will not actually complete the Save operation to a SharePoint Document Library when there are required fields. You get a warning and the document is _not_ placed in SharePoint, but the Fields from the Document Library are attached to your Word document.

In Word, if you want to display the “Save As” dialog box pre-populated to a SharePoint library you do something like this:

dynamic dlg = Application.Dialogs[Word.WdWordDialog.wdDialogFileSaveAs];
dlg.Name = "http://sharepointserver/doclib/filename.docx";
dlg.Show();

This will act the same as the normal “Save As” dialog.

If you want to handle the save process yourself, instead of dlg.Show(), use dlg.Display. This *should* take no action regardless if the user presses Ok or Cancel. If the destination happens to be SharePoint – intsead of doing nothing like it is supposed to – Word happily retreives the Sharepoint properties and attaches them to your document.

In addition to being handy, Word will attach the document properties to Read-Only and Protected files – which is something you cannot do using CustomXMLParts.
And it’s a heck of a lot easier than trying to build and attach them yourself.

While it is undocumented (and therefore subject to change), it is kind of impossible to work around — Word WILL attach the sharepoint properties, so you might as well take advantage of it.

UPDATE 3/20/2012: Unfortunately, I have discovered that this method is unreliable. On one of our user’s machines, the Save As dialog refuses to display the sharepoint folder at all. I don’t know why, but I wouldn’t recommend relying on this.

Viewing and editing Sharepoint properties on a Word document… again

I have posted before about a method of editing the SharePoint Document properties on a Word document in Office 2010 (and Office 2007). I just found something that completely blew my mind. I spent hours and hours battling with CustomXMLParts, Protected and Readonly documents, and a Save-As dialog… and found out that all that effort was pretty much wasted.

Behold:
_Document.ContentTypeProperties Property
Microsoft.Office.Interop.Word.Document.ContentTypeProperties

ContentTypeProperties is a collection of MetaProperty objects representing (possibly among other things) the SharePoint properties displayed in the server document properties panel. And you can edit them.

So instead of a mess of XML xpath, namespaces, exception handling and “_x0020_”‘s , if you want to edit a sharepoint list column called “Task Id”, you would do the following:

doc.ContentTypeProperties["Task Id"].Value = "task1";

(Yes, you still might need some exception handling…)

The CustomXMLParts will be updated appropriately, and when you save it to sharepoint, the properties will be populated.

Have a look at the members of the MetaProperty object:
.Name = sharepoint internal column name: “Task Id”
.Id = escaped column name: “Task_x0020_Id”
The other properties are what you would expect.

Please note that this will only work if the word document has been “touched” by SharePoint. See my next post for a quick (and undocumented) method of getting those properties attached in Word 2010.

Embedding vzaar video in SharePoint 2010 page

vzaar.com is a video hosting service (kind of like Brightcove, only cheaper) that can be used to stream and manage video content when you don’t want to, or cannot serve it up yourself. You could use youtube, but, well, do you really want to embed youtube in your corporate extranet?

In my case, we wanted to video embedded into a SharePoint 2010 page.

Turns out, sharepoint strips out the embed code pasted into the HTML editor for a page. After much searching (see previous post) I came across a method of embedding flash videos, that is made even easier for vzaar videos by the API.

1. Add a Content Editor web part to your page.
If the page is web part page, this is as simple as clicking any “Add Web Part” link in the page editor.
If it is a “wiki-style” page, you will need to go to the Insert ribbon tab, and select Web Part

2. Select the “Media and Content” category, then the “Content Editor” web part and click Add.

3. Open the Content Editor Web Part properties, paste the “basic embed code (api call)” from the vzaar video, click OK
(To get the basic embed code, in your vzaar video library click the Manage link next to the desired video, and scroll to the bottom)
(To open the content editor properties, either click the dropdown in the web part, or click on the web part and use the Ribbon tab)

That’s it. Your video should now show up embedded right in the sharepoint page.

Embedding flash video in SharePoint 2010 page

The SharePoint 2010 page editor allows you to edit the raw HTML for a page with one huge caveat: it strips out anything it considers unsafe. Including object tags you might use to embed a flash video.

There are quite a few articles / forum posts online with workarounds that either don’t work, or are far too complicated for the average power user.

Then I found this blog post:
Adding Flash Content to SharePoint 2010 / Office 365

While I don’t usually post about things other have already figured out, for some reason Bert’s article took me quite a while to find.

I will be posting a simplified version of his steps for use with the vzaar video hosting service soon.

Pre Populate SharePoint Document Properties in a Word Document

The integration between SharePoint and Microsoft office contiunes to improve with every successive release, but as of Office 2010 and SharePoint 2010, there is still a bit of feature gap when it comes to automation.

When a document originates from within SharePoint it is not too bad – you have to do a little CustomXMLPart trickery to set the properties. But what if your file is a SharePoint virgin?

The adding a document to sharepoint adds at least 3 additional Custom Xml Parts to the Word Document – one of them big, complex and guid-filled. To generate these parts would be a bit of a nightmare.

Turns out, you don’t need all of the xml to pre-populate fields. Nor do you need any guids. Here is all the XML you need:

<?xml version="1.0"?>
<p:properties xmlns:p="http://schemas.microsoft.com/office/2006/metadata/properties" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls">
  <documentManagement>
    <SharePoint_x0020_ColumnName>Text Value</SharePoint_x0020_ColumnName>
  </documentManagement>
</p:properties>

I will leave it to you to figure out the column names (hint – spaces become “_x0020_”).

Store that xml bit in a string (say, xmlString), and call Document.CustomXMLParts.Add(xmlString);
Now, when the document is saved to sharepoint, the fields will be pre-populated, all the appropriate xsd and guids updated, and the user gets no errors about missing required fields!