PowerShell Method to Unblock a Workbook with Macros

chrisw76

New Member
Joined
Sep 23, 2016
Messages
7
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Hello all!

I recently found a new way to unblock a file downloaded from the Internet with Macros in it and I thought I'd share.

The two most common ways are (see article here: How to fix “Microsoft has blocked macros” [exceloffthegrid.com]
  1. Right-click on the file in File Explorer and in Properties window check the Unblock checkbox, or
  2. Change the Trust Center settings
However, if you are working in a corporate environment you may find that neither of these options work as the Unblock checkbox may not even show up in the Properties window. So the third option is to use PowerShell to run the cmdlet Unblock-File. This cmdlet removes the Zone.Identifier alternate data stream which has a value of 3 to indicate that it was downloaded from the internet. Once removed Excel thinks it is now a locally created file. Obviously, don't do this unless you are very confident that the VBA contained in the file is not dangerous.

For example:
Code:
Unlock-File -Path <Path to your blocked file>

Cheers, Chris W.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,215,077
Messages
6,122,995
Members
449,094
Latest member
masterms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top