Skip to content

Instantly share code, notes, and snippets.

Created January 18, 2015 09:03
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hinchley/f4bd00110ff1d155be0b to your computer and use it in GitHub Desktop.
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

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

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