<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OfficeDeveloper.NET&#187; Zip File</title>
	<atom:link href="http://officedeveloper.net/tag/zip-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://officedeveloper.net</link>
	<description></description>
	<lastBuildDate>Sat, 12 May 2012 09:40:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>5 Cool Things You Must Know About the New Office 2007 File Formats</title>
		<link>http://officedeveloper.net/2007/01/04/5-cool-things-you-must-know-about-the-new-office-2007-file-formats/</link>
		<comments>http://officedeveloper.net/2007/01/04/5-cool-things-you-must-know-about-the-new-office-2007-file-formats/#comments</comments>
		<pubDate>Thu, 04 Jan 2007 22:11:08 +0000</pubDate>
		<dc:creator>Ty Anderson</dc:creator>
				<category><![CDATA[Office 2007]]></category>
		<category><![CDATA[Office Development]]></category>
		<category><![CDATA[Samples]]></category>
		<category><![CDATA[Cool Thing]]></category>
		<category><![CDATA[Cool Things]]></category>
		<category><![CDATA[Developer Benefits]]></category>
		<category><![CDATA[Development Scenarios]]></category>
		<category><![CDATA[Document Generation]]></category>
		<category><![CDATA[Document Package]]></category>
		<category><![CDATA[Docx File]]></category>
		<category><![CDATA[File Formats]]></category>
		<category><![CDATA[First Glance]]></category>
		<category><![CDATA[Logical Progression]]></category>
		<category><![CDATA[Object Models]]></category>
		<category><![CDATA[Office Document]]></category>
		<category><![CDATA[Office Documents]]></category>
		<category><![CDATA[Sample Application]]></category>
		<category><![CDATA[Ubiquity]]></category>
		<category><![CDATA[Word Folder]]></category>
		<category><![CDATA[Xml Capabilities]]></category>
		<category><![CDATA[Xml Specifications]]></category>
		<category><![CDATA[Xml Work]]></category>
		<category><![CDATA[Zip File]]></category>

		<guid isPermaLink="false">http://officedeveloper.net/?p=10</guid>
		<description><![CDATA[Summary Office 2007 features a new default XML file format that opens a new world of development scenarios to .NET developers. This article explains the developer benefits provided by the new Office Open XML File formats that will be released as part of the 2007 Microsoft Office System. After reading this article you will understand [...]]]></description>
			<content:encoded><![CDATA[<div class="ExternalClass5610F68911494651A09EECC38187B2C4">
<h2>Summary</h2>
<p>Office 2007 features a new default XML file format that opens a new world of development scenarios to .NET developers. This article explains the developer benefits provided by the new Office Open XML File formats that will be released as part of the 2007 Microsoft Office System. After reading this article you will understand the architecture of the new file formats as well as understand how the new formats enhance Office development scenarios. In addition, the article discusses a sample application that illustrates how the new file formats enable Office document generation on the server. </p>
<h3>Cool Thing #1: The New Files are Open and XML </h3>
<p>The new file formats are a logical progression of the XML work done in the most recent versions of Office. The last three versions have incrementally increased the XML capabilities of Office applications to a point that, today, it is possible to generate Office documents through their respective XML specifications (i.e. WordML and SpreadSheetML) without manipulating the Word and Excel object models. Given the ubiquity of XML and the XML features already included in Office 2003, the new default file formats should be viewed as a positive step forward because it places XML front and center in Office</p>
<h4>Architecture&#8211;It&#8217;s a ZIP file!</h4>
<p>At first glance, the most obvious result of the new file formats is that they have a new, 4-character, file extension. For example a Word 2007 document is .docx, Excel 2007 is .xlsx, and PowerPoint 2007 is .pptx (see Sidebar 1 for full listing of the new file formats). In reality, any file created with these applications is just a standard ZIP file. You can change its extension to .zip, open it with your favorite ZIP file tool, and view the contents.&#160; Let&#8217;s take a look at a typical .docx file.</p>
<p class="style1"><a href="http://officedeveloper.net/wp-content/uploads/2008/08/figure1.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="362" alt="Figure1" src="http://officedeveloper.net/wp-content/uploads/2008/08/figure1-thumb.png" width="422" border="0" /></a> </p>
<h6><strong>Figure 1. The Contents of a Word 2007 Document Package&#8217;s Word Folder</strong></h6>
<h4>Parts</h4>
<p>Take another look at Figure 1 and notice how the content of the <strong>word</strong> is split into a series of XML files. Each of these XML files is a document part that stores a specific portion of content. For example, all header content resides in the Header<em>n</em>.xml files, the fonts in the FontTable.xml file, the document text and WordProcessingML tags in the Document.xml file, etc. This architecture makes manipulating documents as easy as opening a ZIP file, finding the desired document part, and editing or swapping out its content. This is something I will explain in more detail at the end of the article.</p>
<h4>Relationships</h4>
<p>The package contains all the parts that comprise a document and the parts contain the different elements that combine to build a document. It is the <em>relationships</em> that glue the different parts together by defining how they are linked together, thus they are extremely important. Below is an example relationships document named <strong>document.xml.rels </strong>that specifies the relationships for the <strong>Document.XML</strong> file contained in the document package.:       </p>
<p><span class="style2">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot; ?&gt;        <br />&lt;Relationships xmlns=&quot;http://schemas.microsoft.com/package/2005/06/relationships&quot;&gt;         <br />&#160; &lt;Relationship Id=&quot;rId8&quot; Type=&quot;http://schemas.microsoft.com/office/2006/relationships/officeDocument&quot; Target=&quot;glossary/document.xml&quot; /&gt;         <br />&#160; &lt;Relationship Id=&quot;rId3&quot; Type=&quot;http://schemas.microsoft.com/office/2006/relationships/wordStyles&quot; Target=&quot;styles.xml&quot; /&gt;         <br />&#160; &lt;Relationship Id=&quot;rId7&quot; Type=&quot;http://schemas.microsoft.com/office/2006/relationships/wordFooter&quot; Target=&quot;footer1.xml&quot; /&gt;         <br />&#160; &lt;Relationship Id=&quot;rId2&quot; Type=&quot;http://schemas.microsoft.com/office/2006/relationships/wordLists&quot; Target=&quot;lists.xml&quot; /&gt;         <br />&#160; &lt;Relationship Id=&quot;rId1&quot; Type=&quot;http://schemas.microsoft.com/office/2006/relationships/wordFontTable&quot; Target=&quot;fontTable.xml&quot; /&gt;         <br />&#160; &lt;Relationship Id=&quot;rId6&quot; Type=&quot;http://schemas.microsoft.com/office/2006/relationships/wordHeader&quot; Target=&quot;header2.xml&quot; /&gt;         <br />&#160; &lt;Relationship Id=&quot;rId5&quot; Type=&quot;http://schemas.microsoft.com/office/2006/relationships/wordHeader&quot; Target=&quot;header1.xml&quot; /&gt;         <br />&#160; &lt;Relationship Id=&quot;rId4&quot; Type=&quot;http://schemas.microsoft.com/office/2006/relationships/wordSettings&quot; Target=&quot;settings.xml&quot; /&gt;         <br />&#160; &lt;Relationship Id=&quot;rId9&quot; Type=&quot;http://schemas.microsoft.com/office/2006/relationships/theme&quot; Target=&quot;theme/theme1.xml&quot; /&gt;         <br />&lt;/Relationships&gt;</span></p>
<p>This document defines nine relationships for Document.xml. For each relationship, the document defines both the content type and location of the related file. These relationship definitions are very important as part names do not persist across saves. Thus, when Word opens a document package it uses the relationships defined in the package to locate the document parts and build out the document in the Word UI.      </p>
<p><strong>Cool Thing #1 Key Takeaway:</strong> The Office Open XML file formats free developers from the tyranny of the binary file format. The new files are now wide-open and accessible from any application without manipulating the Office application word models. If you are tempted to say, &quot;Big deal! I can do whatever I want with Office files already!&quot;, keep reading.       <br /><strong>       <br />To Learn Even More: </strong>Download (<em>and read!) </em>the Microsoft Office Open XML Formats Guide <a href="http://www.microsoft.com/office/preview/developers/fileguide.mspx">here</a>.</p>
<p>&#160;</p>
<h3>Cool Thing #2: The New Formats Make Anything Possible</h3>
<p>Well they may not bring about world peace, but the new formats sure make developing solutions that include Office files a lot less stressful. No longer does a developer have to go through the Office applications just to make wholesale changes to one or more documents. Instead of needing to know the intricacies of an Office application&#8217;s object model, a developer only needs to know how to peruse the contents of a ZIP file (the document package) to find and edit the desired document parts (the various xml files included in the package). If you think about it for a few minutes it doesn&#8217;t take much brainpower to think of some interesting new Office-related developer scenarios.      </p>
<p>Here are a few application ideas I thought of while researching this article: </p>
<ul type="disc">
<li><strong>Project Document Generator:</strong> I am in the services business, and anytime I win a new project, I need to create several new documents: Contract, Work Order, Change Order Template, etc. With the new format, I could now build an application that allows me to select a customer from my CRM system, input a project name, and generate all required documents while I sip on my Starbucks. </li>
<li><strong>Report Writing: </strong>Office applications were never meant to be automated on a server. But by taking advantage of the new file formats, I could now generate 1,000s of Word, Excel, or PowerPoint files on the server without a worry. A good idea for an app would be a reporting application that e-mails Excel files that shows key activity metrics to insurance agents.<strong></strong> </li>
<li><strong>Theme Library: </strong>This application would allow me to fulfill my creative design dream of selling document designs to Office users all over the planet. This application would allow a user to browse different themes from the Web or on their file system and apply them to the open document. Even better, they would be able to pick a theme and apply it to 100s or 1000s of documents at a time. </li>
</ul>
<p>Each of these ideas is made possible (or made simpler) by the new, open file formats.      </p>
<p><strong>Cool Thing #2 Key Takeaway: </strong>The new XML file formats create new possibilities when developing solutions for your clients by freeing Office files from their binary format, as well as their host application&#8217;s object model. In addition, Microsoft has submitted the new file formats to ECMA for standardization. Once accepted, the ECMA standardization will encourage wide-spread implementation and adoption of the file formats by non-Microsoft applications. The end-goal here is to increase Office document interoperability across platforms and back-office applications.       </p>
<p><strong>To Learn Even More:: </strong>Download (<em>and read!) </em>the Microsoft Office Open XML Formats Architecture Guide <a href="http://www.microsoft.com/office/preview/developers/devpaper.mspx">here</a>. Take a look at the ECMA proposal <a href="http://www.ecma-international.org/memento/TC45.htm">here</a>. The initial draft of the proposal can be downloaded <a href="http://www.ecma-international.org/activities/Office Open XML Formats/TC45_FD_XML_docform.zip">here</a>.</p>
<p>&#160;</p>
<h3>Cool Thing #3: You Can add Your Own Content to the Document Package</h3>
<p>Like all other Microsoft technologies, the document packages are architected to provide for extensibility. It is quite possible to include custom XML data inside the package and then reference the custom data inside the document package. The custom data will reside in a special folder named <strong>dataStore</strong> which resides in the package&#8217;s <strong>word </strong>folder (or <strong>excel</strong> for Excel, <strong>ppt</strong> for PowerPoint). This means it is still possible to attach XML schemas to documents and include dynamic XML data. This also means that at any time the custom XML data is updated, those changes will be reflected in the document.       </p>
<p><strong>Cool Thing #3 Key Takeaway: </strong>The new file formats are extensible and can include custom data for use within the document itself.       <br /><strong>       <br />To Learn Even More:</strong> Read Brian Jones&#8217;s <a href="http://blogs.msdn.com/brian_jones/default.aspx">blog</a>, especially <a href="http://blogs.msdn.com/brian_jones/archive/2005/11/04/489223.aspx">this post</a>.</p>
<p>&#160;</p>
<h3>Cool Thing #4: The System.IO.Packaging Namespace</h3>
<p>If you haven&#8217;t been wondering how to manipulate the new file formats with code yet, you were bound to wonder soon. The answer is that the <strong>System.IO.Packaging</strong> namespace contains all the classes you need to code against the new formats. The new Office file formats are based on the Open Packaging Conventions (as is the XML Paper Format) which will be released with Windows Vista and is part of Windows Presentation Foundation.       </p>
<p>Although you could use any tool that has the capability to manipulate ZIP files, you don&#8217;t need them as the System.IO.Packaging namespace is designed for this purposes&#8211;making manipulating the document package as simple as opening a ZIP file, querying the relationships for the desired content types, and then adding, editing, or deleting files.       <br />The key objects (or at least for the sample discussed next) are defined in Table 1.</p>
<h5><strong>Table 1. Key Classes included in System.IO.Packaging.</strong></h5>
<table cellspacing="0" cellpadding="0" border="1">
<tbody>
<tr>
<td valign="top" width="115" bgcolor="#000000">
<p class="style3" align="center">Class</p>
</td>
<td valign="top" width="238" bgcolor="#000000">
<p class="style3" align="center">Description</p>
</td>
<td valign="top" width="238" bgcolor="#000000">
<p class="style3" align="center">Key Usage </p>
</td>
</tr>
<tr>
<td valign="top" width="115">
<p>Package</p>
</td>
<td valign="top" width="238">
<p>Represents the docx, xlsx, pptx, etc., document package (or any other document that conforms to the XML Paper Format).</p>
</td>
<td valign="top" width="238">
<p>This is the top-level class and should be used to open a document package and browse its contents.</p>
</td>
</tr>
<tr>
<td valign="top" width="115">
<p>PackagePart</p>
</td>
<td valign="top" width="238">
<p>Represents a file object stored in a Package. This is typically the various XML file document parts, but can also be images, binary objects, etc.</p>
</td>
<td valign="top" width="238">
<p>This class contains all information for a referenced part including its relationships, location in the package, and content.</p>
</td>
</tr>
<tr>
<td valign="top" width="115">
<p>PackageRelationship</p>
</td>
<td valign="top" width="238">
<p>Represents a relationship between Package or PackagePart and a target PackagePart (i.e. Document.xml and Header1.xml)</p>
</td>
<td valign="top" width="238">
<p>By looking up a relationship to a package or packagepart, you can then find the location of other packageparts and navigate to them.</p>
</td>
</tr>
<tr>
<td valign="top" width="115">
<p>PackageURIHelper</p>
</td>
<td valign="top" width="238">
<p>Contains methods for composing and parsing package objects.</p>
</td>
<td valign="top" width="238">
<p>Primarily used to locate a package part from a specified URI.</p>
</td>
</tr>
</tbody>
</table>
<p><strong>Cool Thing #4 Key Takeaway: </strong>The new file formats even come with a specialized set of classes contained in the System.IO.Packaging namespace. Theses classes provide a developer with the ability to create, modify, and delete document packages.       </p>
<p><strong>To Learn even more: </strong>Download the WinFX SDK <a href="http://msdn.microsoft.com/winfx/">here</a>. Also read <a href="http://blogs.msdn.com/kevinboske/">Kevin Boske&#8217;s blog</a> (not many posts right now but I am sure more will follow). Kevin is the Office Programmability Program Manager so his blog is worth subscribing to.</p>
<p>&#160;</p>
<h3>Cool Thing #5: The New File Formats Are Easy to Build Upon (Sample Application Overview)</h3>
<p>Once you get the hang of it, the new file formats are really simple to develop against (with one minor issue &#8211; see Dev Tip below). To demonstrate, I created a sample Web page that allows a user to pick a document and then select between several options for headers and footers (see Figure 2). Once the user makes their selections, they can press the &quot;Build Document&quot; button causing the Web page to open the selected document and insert the desired header and footer.      </p>
<p><span class="style1"><strong><img alt="Figure2" src="/Lists/Photos/Figure2.png" /></strong></span></p>
<p><span class="style1"><a href="http://officedeveloper.net/wp-content/uploads/2008/08/figure2.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="472" alt="Figure2" src="http://officedeveloper.net/wp-content/uploads/2008/08/figure2-thumb.png" width="599" border="0" /></a> </span></p>
<h5><strong>Figure 2. Sample Web Page </strong></h5>
<p>Listing 1 contains the complete listing of the code behind the page:</p>
<h5><strong>Listing 1. The default Page Code Listing of the Sample Web Application</strong></h5>
<p class="style2">Imports System.IO.Packaging      <br />Imports System.IO       <br />Imports System</p>
<p class="style4">&#160;</p>
<p class="style2">Partial Class _Default      <br />&#160; Inherits System.Web.UI.Page</p>
<p class="style2">&#160; Private Sub InsertParts(ByVal filePath As String, ByVal PartName As String)</p>
<p class="style2">&#160;&#160;&#160; Dim relType As String = &quot;http://schemas.microsoft.com/office/2006/relationships/officeDocument&quot;      <br />&#160;&#160;&#160; Dim partRelType As String</p>
<p class="style2">&#160;&#160;&#160; &#8216;//Determine what type of part we are inserting      <br />&#160;&#160;&#160; &#8216;//and set reference to the appropriate relationship type.       <br />&#160;&#160;&#160; Select Case PartName       <br />&#160;&#160;&#160;&#160;&#160; Case &quot;Header&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; partRelType = &quot;http://schemas.microsoft.com/office/2006/relationships/wordHeader&quot;       <br />&#160;&#160;&#160;&#160;&#160; Case &quot;Footer&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; partRelType = &quot;http://schemas.microsoft.com/office/2006/relationships/wordFooter&quot;       <br />&#160;&#160;&#160;&#160;&#160; Case Else</p>
<p class="style2">&#160;&#160;&#160; End Select</p>
<p class="style4">&#160;</p>
<p class="style2">&#160;&#160;&#160; Dim pkgPart As PackagePart      <br />&#160;&#160;&#160; Dim docUri As Uri</p>
<p class="style4">&#160;</p>
<p class="style2">&#160;&#160;&#160; &#8216;//Open the package with Read/Write permission      <br />&#160;&#160;&#160; Dim pkg As Package = Package.Open(filePath, IO.FileMode.Open, IO.FileAccess.ReadWrite)</p>
<p class="style2">&#160;&#160;&#160; &#8216;//Get the start part&#8230;[Content_Types].xml      <br />&#160;&#160;&#160; Dim rel As PackageRelationship       <br />&#160;&#160;&#160; &#8216;//Peruse the relationships of document type       <br />&#160;&#160;&#160; For Each rel In pkg.GetRelationshipsByType(relType)</p>
<p class="style2">&#160;&#160;&#160;&#160;&#160; Dim u As New Uri(&quot;/&quot;, UriKind.Relative)      <br />&#160;&#160;&#160;&#160;&#160; &#8216;//FInd the full path of the Target URI       <br />&#160;&#160;&#160;&#160;&#160; docUri = PackUriHelper.ResolvePartUri(u, rel.TargetUri)       <br />&#160;&#160;&#160;&#160;&#160; &#8216;//Retrieve the part       <br />&#160;&#160;&#160;&#160;&#160; pkgPart = pkg.GetPart(docUri)</p>
<p class="style2">&#160;&#160;&#160;&#160;&#160; &#8216;//If we are at the Document part, take action.      <br />&#160;&#160;&#160;&#160;&#160; If pkgPart.Uri.OriginalString = &quot;/word/document.xml&quot; Then</p>
<p class="style2">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216;//Find and delete the current Part      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim rel2 As PackageRelationship</p>
<p class="style2">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216;//Peruse the relationships of DOcument.XML      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216;//to find the desired part.       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; For Each rel2 In pkgPart.GetRelationshipsByType(partRelType)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim partURI As Uri = PackUriHelper.ResolvePartUri(docUri, rel2.TargetUri)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim hdrPart As PackagePart = pkg.GetPart(partURI)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216;//Delete the exsiting Part       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pkg.DeletePart(partURI)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216;//Create a new package part that will store the new part       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim pkgPartNew As PackagePart = pkg.CreatePart(partURI, System.Net.Mime.MediaTypeNames.Text.Xml)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216;//Insert the contents of the new part       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim fs As FileStream = New FileStream(lstFooters.SelectedValue.ToString, FileMode.Open, FileAccess.Read)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CopyStream(fs, pkgPartNew.GetStream)</p>
<p class="style2">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Next      <br />&#160;&#160;&#160;&#160;&#160; End If       <br />&#160;&#160;&#160; Next       <br />&#160;&#160;&#160; &#8216;//Close saves the package.       <br />&#160;&#160;&#160; pkg.Close()</p>
<p class="style2">&#160; End Sub</p>
<p class="style4">&#160;</p>
<p class="style2">&#160; Private Sub CopyStream(ByVal source As Stream, ByRef target As Stream)</p>
<p class="style2">&#160;&#160;&#160; Dim size As Integer = source.Length      <br />&#160;&#160;&#160; Dim bytes(size) As Byte       <br />&#160;&#160;&#160; Dim numBytes As Integer       <br />&#160;&#160;&#160; numBytes = source.Read(bytes, 0, size)       <br />&#160;&#160;&#160; While numBytes &gt; 0       <br />&#160;&#160;&#160;&#160;&#160; target.Write(bytes, 0, numBytes)       <br />&#160;&#160;&#160;&#160;&#160; numBytes = source.Read(bytes, 0, size)</p>
<p class="style2">&#160;&#160;&#160; End While</p>
<p class="style4">&#160;</p>
<p class="style2">&#160; End Sub</p>
<p class="style2">&#160; Protected Sub btnBuildIt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBuildIt.Click      <br />&#160;&#160;&#160; InsertParts(lstDocuments.SelectedValue.ToString, &quot;Header&quot;)       <br />&#160;&#160;&#160; InsertParts(lstDocuments.SelectedValue.ToString, &quot;Footer&quot;)       <br />&#160; End Sub       <br />End Class</p>
<p>The application logic follows this flow:</p>
<ol type="1">
<li>The click event of the Web page&#8217;s button control (<strong>btnBuildIt</strong>) makes two calls to the <strong>InsertParts</strong> method included in the pages class. In each call, I specify the type of part (header or footer) and the selected document&#8217;s location. The <strong>lstDocuments</strong> control provides the path of the document via its <strong>SelectedValue</strong> property. </li>
<li>The <strong>InsertParts</strong> method first determines what type of content will be inserted and sets variables for the specified content type. Next the method opens the document package and finds the location of the specified part and deletes it using a <strong>Package</strong> object. </li>
<li>In order to insert the new part, the method uses a <strong>PackagePart</strong> object to create a new document part and saves it to the same location in the package as the one deleted in step #2. </li>
<li>In the last step, the method calls the <strong>CopyStream</strong> method and passes a <strong>FileStream</strong> object that represents the content of the part to be inserted as well as a <strong>Stream </strong>object representing the blank package part created in step #3.<strong> CopyStream</strong> takes the two <strong>Stream </strong>object and copies the source into the target. I defined the target as <strong>ByRef</strong> so that any changes made are reflected in the passed object. </li>
</ol>
<p>When you run the code, the original document quickly updates with my choices for header and footer (see Figure 3).&#160; <br /><a href="http://officedeveloper.net/wp-content/uploads/2008/08/figure3.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="326" alt="Figure3" src="http://officedeveloper.net/wp-content/uploads/2008/08/figure3-thumb.png" width="895" border="0" /></a>       <br />&#160; </p>
<h5><strong>Figure 3. The Before and After Versions of the Selected Document</strong></h5>
<p><strong>Cool Thing #5 Key Takeaway:</strong> Manipulating the new file formats in code is a simple process that does not require a lot of effort.</p>
<p><strong>To Learn even more: </strong>Look for more content on the <a href="http://www.devx.com/OfficeProDev">Devx</a> Microsoft Office Professional Developer Portal, as well as <a href="http://msdn.microsoft.com/">MSDN</a>.</p>
<p>Office 2007&#8242;s new Open XML file format provides extensive capabilities to a developer. As this article has pointed out, there is a lot to be excited about and to learn. </p>
<p>&#8211;Ty</p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://officedeveloper.net/2007/01/04/5-cool-things-you-must-know-about-the-new-office-2007-file-formats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

