SharePoint Online: Open Documents in Client Applications by Default
Requirement: Open documents in client applications by default in SharePoint Online.
How to Open Documents in Client Application in SharePoint Online?
Do SharePoint Online documents open in the browser instead of the client application? By default, documents such as Word, Excel, PowerPoint, etc. open in the browser with Office web apps in SharePoint Online. However, the Office web applications like Word Online don’t give you full functionality as in the client-installed application. So, if you want to change this behavior at the site collection level, You have to activate a feature called “Open Documents in Client Applications by Default”. Here is how to activate the feature:
- Open your SharePoint Online site and click on the gear icon in the top-right corner >> Choose Site Settings.
- On the Site Settings page, click on “Site collection features” under the “Site Collection Administration” section.
- Click on the “Activate” button next to the “Open Documents in Client Applications by Default” feature.
Activating the feature to open documents in client applications for a single site collection is straightforward. How about activating the feature for all site collections?
SharePoint Online: PowerShell to Activate the “Open in client application” Feature for All Sites
When the “Open Documents in Client Applications by Default” feature is activated, Office documents will open in the Office client application by default. E.g., an Excel spreadsheet will open in Microsoft Excel installed on the client’s computer. When this feature is deactivated, an Excel Spreadsheet will open in Office Web Applications within the web browser. Here is the PowerShell to set open documents in client application settings for all site collections in a tenant by activating the feature discussed above.
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Function to Activate Feature in SharePoint Online
Function Activate-SPOFeature
{
Param ($SiteURL,$FeatureGuid)
Try
{
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Credential.Username, $Credential.Password)
$Ctx.Credentials = $Credentials
$Site=$Ctx.Site
#Get the Feature
$Feature = $Site.Features.GetById($FeatureGuid)
$Ctx.Load($Feature)
$Ctx.ExecuteQuery()
#Activate the feature if its not activated already
Write-Host "Activating Feature $($FeatureStatus.DisplayName) in Site $SiteURL"
if($Feature.DefinitionId -eq $null)
{
#sharepoint online powershell open in client application
$Site.Features.Add($FeatureGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None) | Out-Null
$Ctx.ExecuteQuery()
Write-Host "`t Feature Activated!" -ForegroundColor Green
}
else
{
Write-host "`t Feature is Already Active on the Site collection!" -ForegroundColor Yellow
}
}
Catch
{
write-host "Error Activating Feature: $($_.Exception.Message)" -foregroundcolor Red
}
}
#Parameters to Activate Feature
$AdminSiteURL = "https://Crescent-admin.sharepoint.com/"
$FeatureGuid= [System.Guid] ("8a4b8de2-6fd8-41e9-923c-c7c3c00f8295")
#Get Credentials to connect
$Credential = Get-Credential
#Connect To SharePoint Online Admin Center
Connect-SPOService -URL $AdminSiteURL -Credential $Credential
#Get All Site collection and loop through
ForEach($Site in (Get-SPOSite -Limit ALL))
{
#Activate Feature
Activate-SPOFeature -Site $Site.URL -FeatureGuid $FeatureGuid
}
PnP PowerShell to Enable Documents to Open in Client Applications by Default
By default, SharePoint Online opens documents in the browser, but if you prefer to work with documents in client applications, you can change the settings to set to open documents in client applications by default. We can enable the feature that sets all documents to open in a client application in a SharePoint Online site with PnP PowerShell as well:
#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$FeatureID= "8a4b8de2-6fd8-41e9-923c-c7c3c00f8295" #Open Documents in Client Applications by Default
#Connect to SharePoint Online site
Connect-PnPOnline $SiteURL -Interactive
#Get the Feature
$Feature = Get-PnPFeature -Scope Site -Identity $FeatureID
#Get the Feature status
If($Feature.DefinitionId -eq $null)
{
#Activate the Feature
Enable-PnPFeature -Identity $FeatureID -Scope Site
Write-host -f Green "Feature Activated Successfully!"
}
Else
{
Write-host -f Yellow "Feature is already activated!"
}
SharePoint Online: Configure Open in Client Application at Document Library Level
In SharePoint Online, you can configure the open document in the browser or client application setting from the document library’s settings.
- Navigate to the Document Library >> Click on Settings gear >> Library Settings from the menu.
- Under General Settings, Click on the “Advanced Settings” link
- Under the “Opening Documents in the Browser” section, choose “Open in the client application” or “Open in the browser” option according to your requirement.
This overrides the setting applied at the site collection level and opens documents in the client application instead of the browser.
PowerShell to Set the Default Open Behavior for Document Library
To configure the default open behavior either to the browser or client application, use this PowerShell script:
#Parameters
$SiteCollURL = "https://crescent.sharepoint.com/sites/retail"
$ListName = "Documents"
Try {
#Connect to PnP Online
Connect-PnPOnline -Url $SiteCollURL -Interactive
#Get the Document Library
$List = Get-PnPList $ListName -Includes DefaultItemOpenInBrowser
#Set the Default Open behaviour for documents to client app
$List.DefaultItemOpenInBrowser = $False
$List.Update()
Invoke-PnPQuery
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
Wrapping up
In conclusion, setting open documents in client applications by default in SharePoint Online can provide several benefits for collaborating on documents and improving productivity, enhanced functionality, Familiarity, etc. By following the steps and best practices outlined in this article, you can easily set open documents in client applications and enjoy the benefits of this powerful feature.
CSOM and Microsoft.Online.SharePoint.PowerShell work together?
I believe it only OPENS Microsoft based applications and not any others correct?
For example an autocad (.dwg) or acrobat (.pdf) or photoshop (.psd) or illustrator (.eps), etc… file via the web browser, correct?
so how I can I make it open automatically using the desktop application stored on the sharepoint online document library then like the ones I listed above if these applications were installed on that desktop?
Can this be done or does the library have to be sync’d for it to work first? if sync’d to our personal one drive or organizational onedrive?
here is my observation
We are now running SharePoint Online (SPO)
We will ditch if we can the idea of a network file storage and move our department files over to (SPO).
I hit a bit of a snag with non-MS applications while trying to open them through the browser.
We have autocad files in our document library. When users try and click on it, it automatically tries and open it thorough autodesk web app, which we never have.
I have activated the setting for the site to open in client application through the site settings and also the same in the document library settings advanced settings.
My questions are:
1. Why did SPO show us the autodesk wep app option? Is it by default built into share point? How or why did that appear?
2. Is the “open with client applications” only work for ms office products and nothing else like acrobat pdf, autocad, or other programs installed on the users computer? For example, if we have an application called ABC and creates a file with an extension .123 and we try and click in it we n share point, would it not show or gives us the option to “open with” ABC application on the user’s desktop?
3. How can we have users just click on an autocad file, .dwg in sharepoint and have Autocad automatically open via the browser?
4. Same with say a .pdf file via the browser?
5. Or do we have to sync it and then open the file that way via file explorer and it will automatically open and use Autocad similar to that of a regular or network drive?
6. The sync is soooo unbearably and unacceptably slow unlike Dropbox.
Any suggestions? or impossible to use with Autocad?
Of course we just need a setting not covered (tested) in the blogpost. We want the libraries to follow the server (open in client). Why, because there is a diffrence between setting library Open in Client, or follow the server (open in clienty). The latter is more often working (ie open in client). We activated the feature on al site collections.
Wanting to set all libraries to follow the server (open in client) to we found that $list.DefaultItemOpenUseListSetting = $false will raise an error: Any ideas ? Again un undocumented change ?
‘DefaultItemOpenUseListSetting’ is a ReadOnly property.
+ $list2.DefaultItemOpenUseListSetting = $false # FollowServer
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
So to program the behaviour for a library this has been changed
$List.DefaultItemOpenInBrowser = $False ; $List.Update()
it used to be $list.DefaultItemOpen = “PreferClient” or $list.DefaultItemOpen = “Browser”
Would this script be applicable to OneDrive for Business? Have a request to apply this for OneDrive for Business users organization-wide.
This doesn’t exactly default it across the board. It gives people a popup where they can select which option they want to default. I now have people who accidentally selected the wrong default and cannot find anything online about how an individual can change that default. Everywhere I find has this same universal change that is done by an admin.
Is there a way to do this through Power Automate using the REST API?
I am trying to accomplish the same function using Enable-PnPFeature
Enable-PnPFeature -Identity “8a4b8de2-6fd8-41e9-923c-c7c3c00f8295
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/enable-pnpfeature?view=sharepoint-ps
Any ideas why it might not be working?
Use the “Scope” Parameter as “Site” in the cmdlet: Enable-PnPFeature -Identity $FeatureID -Scope Site
Why don’t we have any method in SharePoint Online to Configure Open in Client Application at Document Library Level using CSOM?
Well, This property is not available in CSOM yet!
Thanks so much for this Salaudeen ! But it doesn’t work for MFA enabled environments. I’m getting this error
Connect-SPOService : The sign-in name or password does not match one in the Microsoft account system.
At line:55 char:1
+ Connect-SPOService -URL $AdminSiteURL -Credential $Credential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-SPOService], IdcrlException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService
On MFA enabled environments, You can simply remove the “Credential” parameter from Connect-SPOService cmdlet, and you’ll get a authentication prompt with MFA support. So, instead of:
Connect-SPOService -URL $AdminSiteURL -Credential $Credential
use:
Connect-SPOService -URL $AdminSiteURL
You can refer this post: Handling MFA in SharePoint Online PowerShell scripts
This script has just what we need (and seems to be the only one with the solution) but when we run it we get this error on every site: Error Activating Feature: Exception calling “.ctor” with “2” argument(s): “The ‘username’ argument cannot be null.
Parameter name: username”. Has something in SharePoint Online changed since this script was created?
Script updated to get credentials. Try now!
The above settings are not working in Chrome or Firefox.Any seetings to do with chrome