OpenXML and PowerShell

While preparing for this months UK user group talk on PowerShell and Office I decided I wanted to include a look at working with the OpenXML format for Office documents that was introduced in Office 2007. These are the .docx and .xlsx versions of Word and Excel respectively.

When writing PowerShell in Practice ( I included a small section on working with Word and Excel. This contained a bit on using OpenXML.

I’ve rebuilt my system to Windows 7 since those days so needed to re-install the OpenXML support. I went searching and found it on codeplex -

The latest release is 1.1.1

Codeplex contains the source code. You will need Visual Studio and a copy of the OpenXML SDK to compile it. The link given on codeplex for the SDK is wrong. You need to use these links

Version 1

Version 2

Pre-compiled binaries

There is a problem in that version 1 of the SDK won’t install on Windows 7 and if you want to use the pre-compiled binaries instead of compiling your own they are created with version 1. This causes errors when SDK 2.0 is used on Windows 7 (with Office 2010).

A couple of code changes are needed if you want to compile the code against version 2 of the SDK – see for the code changes

This seems to work OK and a way to load the snapin as a module was given here

I’ll be doing some more testing and will report any issues. So far all of my old openxml scripts just work.

If anyone wants a copy of the binaries just leave a comment and I’ll post them

Leave a Reply