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
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
- Open VS Code
- Go to Extensions view (
Ctrl+Shift+X or Cmd+Shift+X)
- Search for "O365 Smart Open"
- Click Install
Required: This extension requires you to register your own Azure AD application (one-time setup, ~5 minutes).
Register Azure AD Application
- Go to Azure Portal
- Navigate to Azure Active Directory (or Microsoft Entra ID)
- Click App registrations → + New registration
- Fill in:
- Name:
O365 Smart Open (or any name)
- Supported account types: Choose based on your needs
- Redirect URI: Leave empty
- Click Register
- In your app registration, go to Authentication
- Scroll to Advanced settings
- Under Allow public client flows, toggle to Yes
- Click Save
Add API Permissions
- Go to API permissions → + Add a permission
- Select Microsoft Graph → Delegated permissions
- Add:
User.Read, Files.Read, Files.Read.All
- Click Add permissions
- Important: Click Grant admin consent if you're an admin, or ask your admin
Get Your IDs
- Go to Overview in your app registration
- Copy the Application (client) ID
- Copy the Directory (tenant) ID
- Open VS Code Settings (
Ctrl+, or Cmd+,)
- Search for
o365SmartOpen.clientId and paste your Application (client) ID
- 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
| |