Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Disable Microsoft Office 2013 Border Shadow with PowerShell
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
namespace Utilities {
public static class Display {
private const uint WM_USER = 0x0400;
private const uint WM_MSO = WM_USER + 0x0900;
private const uint WM_MSO_WPARAM_OMFRAMEENABLESHADOW = 0x0075;
private const uint WM_MSO_LPARAM_SHADOW_DISABLED = 0x0000;
private const uint WM_MSO_LPARAM_SHADOW_ENABLED = 0x0001;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(
IntPtr hWnd,
UInt32 Msg,
IntPtr wParam,
IntPtr lParam
public static void DisableShadows(IntPtr hwndOfficeApp) {
(UInt32) WM_MSO,
public static void EnableShadows(IntPtr hwndOfficeApp) {
(UInt32) WM_MSO,
$hwnd = @(Get-Process winword)[0].MainWindowHandle
Copy link

hinchley commented Jan 18, 2015

Copy link

dhermosillo commented Mar 17, 2015

I get:
Cannot convert argument "0", with value: "", for "DisableShadows" to type "System.IntPtr": "Cannot convert null to type
At line:1 char:36

  • [Utilities.Display]::DisableShadows <<<< ($hwnd)
    • CategoryInfo : NotSpecified: (:) [], MethodException
    • FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument

Copy link

JairoQuispe commented Aug 11, 2017

How to enable by default "DisableShadow" ?

Copy link

wdnz commented Jan 25, 2018

Copy link

benyaminl commented Jan 3, 2021

Is there anyway to make it permanent?

Still work with Office 2019 and O365, Just tried as I wrote this question. Seems the article above is already taken down and M$ have no intention to make it as an option for a default option. So Sad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment