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.
Enable Sync to SharePoint Workspace using UI:
Go to Shared Documents=> Library Settings => General Settings => Advanced Settings.
Click Yes in Office Client Availability section.
Click on Ok.
Sync to SharePoint Workspace option is enabled successfully.
Enable Sync to SharePoint Workspace using SharePoint Object Model:
Open Visual Studio 2010.
Go to File => New => Project.
Select Console Application template from the installed templates.
Enter the Name and Click on Ok.
Add the following Reference.
a. Microsoft.SharePoint.dll
Add the following Namespace.
a. Using Microsoft.SharePoint;
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(); } } } } }
Build the solution.
Hit F5.
Enable Sync to SharePoint Workspace using Powershell:
Go to Start => All Programs =>Microsoft SharePoint 2010 Products.
Right click on SharePoint 2010 Management Shell and then click on Run as Administrator.
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" }
Comments