How to enable Sync to SharePoint Workspace for SharePoint document libraries


In this article we will be seeing how to enable Sync to SharePoint Workspace button in the ribbon interface for SharePoint document libraries so that the documents can be synced to SharePoint Workspace and the users can work from offline.

ShrDcLib1.gif

Enable Sync to SharePoint Workspace using UI:

  1. Go to Shared Documents=> Library Settings => General Settings => Advanced Settings.

    ShrDcLib2.gif
     
  2. Click Yes in Office Client Availability section.

    ShrDcLib3.gif
     
  3. Click on Ok.
  4. Sync to SharePoint Workspace option is enabled successfully.

    ShrDcLib4.gif

Enable Sync to SharePoint Workspace using SharePoint Object Model:

  1. Open Visual Studio 2010.
  2. Go to File => New => Project.
  3. Select Console Application template from the installed templates.
  4. Enter the Name and Click on Ok.
  5. Add the following Reference.

    Microsoft.SharePoint.dll

  6. Add the following Namespace.

    Using Microsoft.SharePoint;

  7. Replace Program.cs with the following code.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.SharePoint;
    using System.Text;

    namespace EnableSharePointWorkspace
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (SPSite site = new SPSite("https://servername:1111/sites/ContentTypeHub/"))
                {
                    using (SPWeb web = site.OpenWeb())
                    {                   
                        SPList list = web.Lists.TryGetList("Shared Documents");
                        if (list != null)
                        {
                            //Enable Sync to SharePoint Workspace
                            list.ExcludeFromOfflineClient = false;
                           //To Disable Sync to SharePoint Workspace => list.ExcludeFromOfflineClient = true;
                            list.Update();
                            Console.WriteLine("Sync to SharePoint Workspace is Enabled");
                        }
                        else
                        {
                            Console.WriteLine(list.Title + " does not exists in the site");
                        }
                        Console.ReadLine();
                    }
                }
            }
        }
    }

     

  8. Build the solution.
  9. Hit F5.

Enable Sync to SharePoint Workspace using Powershell:

  1. Go to Start => All Programs =>Microsoft SharePoint 2010 Products.
  2. Right click on SharePoint 2010 Management Shell and then click on Run as Administrator.
  3. Run the following script.

    $site = Get-SPSite "https://serverName:1111/sites/ContentTypeHub"
    $web = $site.OpenWeb()
    $list = $web.Lists.TryGetList("Shared Documents")
    if ($list -ne $null)
    {
    # Enable Sync to SharePoint Workspace
    $list.ExcludeFromOfflineClient = $false
    # To Disable Sync to SharePoint Workspace => $list.ExcludeFromOfflineClient = $true
    $list.Update()
    write-host " Sync to SharePoint Workspace is enabled"
    }
    else
    {
    write-host $list.Title "does not exists in the site"
    }

Up Next
    Ebook Download
    View all
    Learn
    View all