What? You're trying to open an html file with Excel that you just made from scratch [with another app]? Why would you do that? Well, for one, this seems to be the preferred way to use PowerShell to make Excel files when you want to control colors and other UI-specific information along with data. It's kind of strange that, when one of PowerShell's most useful group of functions is centered around creating and manipulating CSV files, you wouldn't have similar modules for Excel, but fine (Scripting Guy says it's because of Excel's heavy use of COM [1]).

So you get a nice html template, you have PowerShell data-i-fy it all up, you go to Excel to open it, and then BAM.

"You are attempting to open a file type (Web Pages and Excel 2003 XML Spreadsheets) that has been blocked by your File Block settings in the Trust Center."

Wait, what? The Trust Center? I mean, I understand when I have to Unblock-File on ps files I've sourced from the Net, but an html file I created (yes, "all by myself") in SeaMonkey [sic]? RLY, Excel?

You can follow the instructions and wade into your Trust Center to say, "Forget it. I want Excel to open ANY html file, whether I created it or not, in spite of the fact that you could've just checked to see if I'd created it and only stopped me if things were much more suspicious." Or you can try to do that and find your company's IT dept has made it impossible to change your Trust Center settings even though you have admin access for nearly anything else.

Well, if you find you're in the second group (the one with not exactly consistently enforced IT security policies) there's a workaround: Put your html file that you want Excel to open in a "trusted location". Who knew? Good thing the bad guys will never learn where the locations are and exploit this extra trust.

Here's a list of Trusted Locations for Excel 2010 -- a list that will look like crud until I monospace it (sauce: [3]):

Default trusted locations                               | Folder desc    | Trusted subfolders
--------------------------------------------------------+----------------+-------------------
Program Files\Microsoft Office\Templates                | App templates  | Allowed
Users\user_name\Appdata\Roaming\Microsoft\Templates     | User templates | Not allowed
Program Files\Microsoft Office\Office14\XLSTART         | Excel startup  | Allowed
Users\user_name\Appdata\Roaming\Microsoft\Excel\XLSTART | User startup   | Not allowed
Program Files\Microsoft Office\Office14\STARTUP         | Office startup | Allowed
Program Files\Microsoft Office\Office14\Library         | Add-ins        | Allowed

If you're not using 2010 or are looking for something similar for Word, etc, that info is here: http://support.microsoft.com/kb/922849

And voila. Look at that html file you painstakingly created and filled with data, now mangled beyond belief by that bastion of spreadsheet integrity, Excel! You're welcome. ;^)

[1] http://blogs.technet.com/b/heyscriptingguy/archive/2014/01/10/powershell-and-excel-fast-safe-and-reliable.aspx [2] http://technet.microsoft.com/en-us/library/hh849924.aspx [3] http://technet.microsoft.com/en-us/library/cc179039(office.14).aspx

Labels: ,