Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>O365 Smart OpenNew to Visual Studio Code? Get it now.
O365 Smart Open

O365 Smart Open

Eric Stoll

|
1 install
| (1) | Free
Intelligently routes Office files: OneDrive files open in Office web (embedded), others open in desktop apps
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

O365 Smart Open

A VS Code/Cursor extension that intelligently routes Office file opens:

  • OneDrive-synced files → Office web (embedded tab)
  • Non-OneDrive files → Office desktop app

Features

  • Automatically intercepts Office file opens from the Explorer
  • Detects OneDrive sync roots from environment variables and configuration
  • Resolves web URLs via Microsoft Graph API
  • Opens OneDrive files in embedded Simple Browser (or external browser)
  • Falls back to desktop apps for non-OneDrive files or when online resolution fails
  • Provides manual override commands

Supported File Formats

Word

  • .docx, .docm, .doc, .dotx, .dotm, .rtf

Excel

  • .xlsx, .xlsm, .xlsb, .xls, .xltx, .xltm

PowerPoint

  • .pptx, .pptm, .ppt, .potx, .potm

Requirements

  • VS Code 1.74.0 or later (or Cursor)
  • Microsoft Office installed (for desktop fallback)
  • Microsoft account with OneDrive access (for online routing)

Quick Start

1. Install the Extension

  1. Open VS Code
  2. Go to Extensions view (Ctrl+Shift+X or Cmd+Shift+X)
  3. Search for "O365 Smart Open"
  4. Click Install

2. Configure Azure AD Authentication

Required: This extension requires you to register your own Azure AD application (one-time setup, ~5 minutes).

Register Azure AD Application

  1. Go to Azure Portal
  2. Navigate to Azure Active Directory (or Microsoft Entra ID)
  3. Click App registrations → + New registration
  4. Fill in:
    • Name: O365 Smart Open (or any name)
    • Supported account types: Choose based on your needs
    • Redirect URI: Leave empty
  5. Click Register

Configure as Public Client

  1. In your app registration, go to Authentication
  2. Scroll to Advanced settings
  3. Under Allow public client flows, toggle to Yes
  4. Click Save

Add API Permissions

  1. Go to API permissions → + Add a permission
  2. Select Microsoft Graph → Delegated permissions
  3. Add: User.Read, Files.Read, Files.Read.All
  4. Click Add permissions
  5. Important: Click Grant admin consent if you're an admin, or ask your admin

Get Your IDs

  1. Go to Overview in your app registration
  2. Copy the Application (client) ID
  3. Copy the Directory (tenant) ID

Configure Extension Settings

  1. Open VS Code Settings (Ctrl+, or Cmd+,)
  2. Search for o365SmartOpen.clientId and paste your Application (client) ID
  3. Search for o365SmartOpen.tenantId and paste your Directory (tenant) ID (recommended for work accounts)

3. Use the Extension

Simply open any Office file from the Explorer:

  • OneDrive files → Opens in Office web (embedded browser)
  • Other files → Opens in desktop Office app

Configuration

Settings

  • o365SmartOpen.clientId (string, required): Your Azure AD Application (client) ID
  • o365SmartOpen.tenantId (string, recommended): Your Directory (tenant) ID. If not set, defaults to organizations
  • o365SmartOpen.oneDriveRoots (array): Manual OneDrive root paths for multiple accounts or SharePoint libraries
  • o365SmartOpen.preferEmbeddedWeb (boolean, default: true): Open in embedded browser vs external browser
  • o365SmartOpen.logLevel (enum, default: info): Logging level (error, warn, info, debug)

Commands

Available via Command Palette (Ctrl+Shift+P) or right-click context menu:

  • Open Online (Embedded) - Force open file online
  • Open in Desktop App - Force open in desktop app
  • Copy Online URL - Copy web URL to clipboard

Troubleshooting

Authentication Issues

  • Invalid grant error:
    • Ensure "Allow public client flows" is enabled in Azure Portal
    • Set o365SmartOpen.tenantId to your Directory (tenant) ID
    • Verify Client ID matches your app registration
  • Admin consent required: Ask your IT admin to grant consent for Files.Read.All in Azure Portal
  • Permission denied: Verify all three API permissions are added (User.Read, Files.Read, Files.Read.All)

Files Not Opening Online

  • Verify the file is in a OneDrive sync folder
  • Check the Output channel "O365 Smart Open" for error messages
  • Ensure the file is synced to OneDrive (not just local)

Getting Help

Check the Output channel "O365 Smart Open" for detailed logs. Set o365SmartOpen.logLevel to debug for more information.

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft