July 1, 2010

How to Open and Edit Microsoft Office Open XML files from Visual Studio

Today, I will show you how to easily open and edit Microsoft Office Open XML files from within Visual Studio. Having worked with Open XML from quite some time, I’ve opened and edited the inner XML of Open XML files (.docx, .pptx, .xlsx) numerous times, though its not too hard to do that, its tiring and cumbersome process (I will write another blog post to tell you how to do that). But I just found a Visual Studio add-on that does that easily.


  • Visual Studio 2010
  • Open XML Package Editor for Visual Studio 2010. Download from here


Once you have both of above setup properly, you are ready to go. I will show the experience below.

  1. Make a document/spreadsheet/slideshow file (For our example, I will create a docx shown as below and save it on desktop named “MyTestDocx.docx”).
  2. Once saved, I will exit word, and open that docx file in Visual Studio 2010.
  3. I can see something like this,
  4. document.xml is the file where most of document’s content is stored. If I double click on that, I see some XML but the way Office 2010 saves XML data is all on same line (to save bytes), I can use visual studio’s format document functionality (Edit->Advanced->Format Document OR Ctrl+E,D), I see something as follows,
  5. To make sure I can change the XML and save the docx from within Visual Studio, I change the term “Test Text here” to “Test Text was here” and save from File menu, and exit Visual Studio. Opening it in Word again, I can see

Though this was a very simple change, the process of editing Open XML file is very simple with the help of OpenXML package editor.