Programmatically manipulate properties in a WordprocessingML file


There is a new article that will be in the June MSDN magazine that shows how to work with a Word document’s properties programmatically. The author, Ken Getz has actually been working on building a collection of code snippets that people can use to do different things with Open XML files. I believe most of the snippets he’s building leverage the WinFX system.io.packaging apis for cracking the ZIP and walking through the relationships (but of course you could use any ZIP library).

I’m not sure when the rest of the code snippets will be posted, but when they are, I’ll definitely link to them. I’m sure you’ll also be able to find them up on openxmldeveloper.org. I’ve actually played around with a number of them already and there are some pretty cool ones. He has is about 10 or so lines of code and it will remove any hidden text from a Word document. I modified it slightly so that you could also specify style names that you want to have removed. An example use of this would be if your company had certain styles to mark text that you didn’t want to be shown externally. You could just run this small bit of code against any files as they posted to any external facing sites.

(man, I’m really loving this Word blogging tool too!)

-Brian

Comments (0)