<?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>esmithy.net &#187; Office</title>
	<atom:link href="http://esmithy.net/category/programming/office/feed/" rel="self" type="application/rss+xml" />
	<link>http://esmithy.net</link>
	<description>Stuff Hammered Out by Eric Smith</description>
	<lastBuildDate>Fri, 02 Jul 2010 20:35:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>.NET Cold Startup Performance: More</title>
		<link>http://esmithy.net/2008/06/03/net-cold-startup-performance-more/</link>
		<comments>http://esmithy.net/2008/06/03/net-cold-startup-performance-more/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 23:36:13 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Office]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://esmithy.net/?p=132</guid>
		<description><![CDATA[A few months ago I wrote about an approach to improving .NET cold startup performance. Here&#8217;s a little more information that I&#8217;ve learned since then. Another useful tool for optimizing cold startup is Microsoft&#8217;s free CLR Profiler 2.0. While this tool has the aesthetics of a wadded-up paper sack, it does have the ability to graph each assembly that gets [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago <a href="2008/03/06/net-cold-startup-performance-an-example/">I wrote about</a> an approach to improving .NET cold startup performance. Here&#8217;s a little more information that I&#8217;ve learned since then.</p>
<p><span id="more-132"></span>Another useful tool for optimizing cold startup is Microsoft&#8217;s free <a href="http://www.microsoft.com/downloads/details.aspx?familyid=A362781C-3870-43BE-8926-862B40AA0CD0&#038;displaylang=en">CLR Profiler 2.0</a>. While this tool has the aesthetics of a wadded-up paper sack, it does have the ability to graph each assembly that gets loaded, and the method that caused it to be loaded. This makes it easier to figure out <em>why</em> a particular assembly got loaded, allowing you to consider whether there might be a way to avoid loading it or postpone loading it until some less critical moment.</p>
<p>To generate the assembly graph, click the <strong>Start Application</strong> button in the profiler. It lets you browse to the executable, which it will then launch. When you close the application, the profiler displays a summary screen with a bunch of information about the managed heap and garbage collection. You can close that window. Instead, go to the main menu and pick <strong>View</strong> &gt; <strong>Assembly Graph</strong>. You&#8217;ll see something like this:</p>
<p style="text-align: center;"> <a href="http://esmithy.net/content/assembly-graph.png"><img class="alignnone size-medium wp-image-133" title="Assembly Graph Window" src="http://esmithy.net/content/assembly-graph-300x181.png" alt="" width="300" height="181" /></a></p>
<p style="text-align: center;">Assembly Graph Window (click for larger image)</p>
<p style="text-align: left;">At the far left edge of the graph, you can see the total number of assemblies (30) that were loaded during the application run. The edges from there represent method calls that caused other assemblies to load. Underneath the method name is the total number assemblies loaded through the full call stack. As you move to the far right side of the graph, you eventually see each individual assembly that is loaded. If you click on a node in the graph it sort of highlights (is <em>plaid</em> technically a highlight color?) the edges in and out of the node. That can be really handy when the graph lines criss-cross over each other.</p>
<p style="text-align: left;">In my case, where I&#8217;m writing a Word add-in, I have some initialization that must happen on the main thread at startup. Other initialization is put on a low priority background thread, which allows Word to start up quickly while continuing to load up the add-in functionality for when it will be used. To get a better picture of startup, I commented out the background thread. Then I looked for call paths that loaded lots of assemblies to figure out if any of those could be deferred to the background thread.</p>
<p style="text-align: left;">I found that making an XML-RPC call was pretty expensive in terms of code loading. The RPC call itself was pretty fast &#8212; just talking to another process on the same machine, but it took loading classes from five additional assemblies just to make the call, which hurts cold startup performance. At this point we&#8217;re trying to figure out if the current performance is acceptable or if we need to tweak the add-in&#8217;s behavior a little to delay the RPC call to the background thread. </p>
]]></content:encoded>
			<wfw:commentRss>http://esmithy.net/2008/06/03/net-cold-startup-performance-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Corrupt docx File After Adding Custom Properties Part</title>
		<link>http://esmithy.net/2008/03/14/corrupt-docx-file-after-adding-custom-properties-part/</link>
		<comments>http://esmithy.net/2008/03/14/corrupt-docx-file-after-adding-custom-properties-part/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 17:15:21 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://esmithy.net/2008/03/14/corrupt-docx-file-after-adding-custom-properties-part/</guid>
		<description><![CDATA[I spent a few days implementing a component that adds some custom properties to Office 2007 files. Using the System.IO.Packaging namespace from .NET 3.0, and looking at some sample code in some Visual Studio snippets, things went pretty smoothly. Just when I thought I was done, though, I tried opening a manipulated .docx file in [...]]]></description>
			<content:encoded><![CDATA[<p>I spent a few days implementing a component that adds some custom properties to Office 2007 files. Using the System.IO.Packaging namespace from .NET 3.0, and looking at some sample code in some <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=8D46C01F-E3F6-4069-869D-90B8B096B556&amp;displaylang=en">Visual Studio snippets</a>, things went pretty smoothly. Just when I thought I was done, though, I tried opening a manipulated .docx file in Word and got the message &#8220;The file is corrupt and cannot be opened.&#8221;</p>
<p><span id="more-129"></span></p>
<p>After reproducing the problem a few times, I knew I needed an automated test for this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>TestMethod<span style="color: #000000;">&#93;</span>
<span style="color: #000000;">&#91;</span>Description<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Files initially without custom properties can be opened in Word after stamping.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #000000;">&#91;</span>Timeout<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">20000</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> CanOpenStamped<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
 <span style="color: #FF0000;">string</span> testFile <span style="color: #008000;">=</span> testData.<span style="color: #0000FF;">GetFile</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;NoCustom.docx&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>Stream s <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> FileStream<span style="color: #000000;">&#40;</span>testFile, FileMode.<span style="color: #0000FF;">Open</span>, FileAccess.<span style="color: #0000FF;">ReadWrite</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
 <span style="color: #000000;">&#123;</span>
 	IStampable stampable <span style="color: #008000;">=</span> handler.<span style="color: #0000FF;">GetStampable</span><span style="color: #000000;">&#40;</span>s<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 	stampable.<span style="color: #0000FF;">StampNew</span><span style="color: #000000;">&#40;</span>Identifier.<span style="color: #0000FF;">Generate</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #666666;">&quot;test server&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #000000;">&#125;</span>	
&nbsp;
 Word.<span style="color: #0000FF;">Application</span> wordApp <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
 Word.<span style="color: #0000FF;">Document</span> wordDoc <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
<span style="color: #0600FF;">try</span>
 <span style="color: #000000;">&#123;</span>
  wordApp <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Word.<span style="color: #0000FF;">Application</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #FF0000;">object</span> fileName <span style="color: #008000;">=</span> testFile<span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// This will throw if there is an error on open:</span>
  wordDoc <span style="color: #008000;">=</span> wordApp.<span style="color: #0000FF;">Documents</span>.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ref</span> fileName, <span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing,
 		<span style="color: #0600FF;">ref</span> missing,<span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing,
 		<span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #000000;">&#125;</span>
 <span style="color: #0600FF;">finally</span>
 <span style="color: #000000;">&#123;</span>
  <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>wordDoc <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    Marshal.<span style="color: #0000FF;">ReleaseComObject</span><span style="color: #000000;">&#40;</span>wordDoc<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>wordApp <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>Word._Application<span style="color: #000000;">&#41;</span>wordApp<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Quit</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing, <span style="color: #0600FF;">ref</span> missing<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    Marshal.<span style="color: #0000FF;">ReleaseComObject</span><span style="color: #000000;">&#40;</span>wordApp<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
 <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>I tried to see if there was any kind of validation tools for OOXML files, but didn&#8217;t find anything too helpful. One person said, &#8220;If it opens in Word, it&#8217;s valid.&#8221; OK, so what if it isn&#8217;t valid? How do I figure it out? There was also a WPML validator, but it was failing on documents created by Word.</p>
<p>I resorted to creating a bad document (using my code) and making a copy and opening it in Word 2007. Word offered to fix the document, so I then had a bad and good version of the document that I could extract and do diffs on. At first, all I was finding were differences that should be irrelevant based solely on XML syntax, or minor things that I honestly didn&#8217;t know whether they mattered.</p>
<p>Ultimately, I discovered that there was a difference in the [ContentTypes].xml file. The good version had:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Override</span> <span style="color: #000066;">PartName</span>=<span style="color: #ff0000;">&quot;/docProps/custom.xml&quot;</span> <span style="color: #000066;">ContentType</span>=<span style="color: #ff0000;">&quot;application/vnd.openxmlformats-officedocument.custom-properties+xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>The bad version didn&#8217;t have such an override. This led me to the code where I created the custom properties part. Changing the specified content type from &#8220;application/xml&#8221; to the content type above fixed the problem. The test passes and hopefully all is now well.</p>
]]></content:encoded>
			<wfw:commentRss>http://esmithy.net/2008/03/14/corrupt-docx-file-after-adding-custom-properties-part/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting the Host&#8217;s Main Window Handle in an Office Add-in</title>
		<link>http://esmithy.net/2008/01/23/getting-the-hosts-main-window-handle-in-an-office-add-in/</link>
		<comments>http://esmithy.net/2008/01/23/getting-the-hosts-main-window-handle-in-an-office-add-in/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 21:26:49 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://esmithy.net/2008/01/23/getting-the-hosts-main-window-handle-in-an-office-add-in/</guid>
		<description><![CDATA[Sometimes you want the window handle of the host application when you&#8217;re writing an Office add-in. Excel includes that as a property of the Application object in newer versions of the object model, but Word and PowerPoint don&#8217;t. I seem to remember some sample code from Microsoft that suggests using FindWindow to get the handle, [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want the window handle of the host application when you&#8217;re writing an Office add-in. Excel includes that as a property of the Application object in newer versions of the object model, but Word and PowerPoint don&#8217;t. I seem to remember some sample code from Microsoft that suggests using FindWindow to get the handle, but that always seems problematic:</p>
<ul>
<li>You can search by class name (e.g. &#8220;OpusApp&#8221; for Word), but what if you somehow have multiple Word processes running? Which window do you get?</li>
<li>You can search by window text, but it can be really hard to figure out what the window text is.</li>
<li>You can set the Caption property on the Application object to some magic text and search for a window with the magic text, but Word throws all kinds of other stuff into the caption so this generally doesn&#8217;t work reliably.</li>
</ul>
<p>Instead, if you&#8217;re using managed code, you can just do this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">IntPtr hwnd <span style="color: #008000;">=</span> Process.<span style="color: #0000FF;">GetCurrentProcess</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">MainWindowHandle</span><span style="color: #008000;">;</span></pre></div></div>

<p>Underneath this uses <code>EnumWindows</code> and <code>GetWindowThreadProcessId</code> to find the right window.</p>
]]></content:encoded>
			<wfw:commentRss>http://esmithy.net/2008/01/23/getting-the-hosts-main-window-handle-in-an-office-add-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paste Special Macro for Word</title>
		<link>http://esmithy.net/2007/12/31/paste-special-macro-for-word/</link>
		<comments>http://esmithy.net/2007/12/31/paste-special-macro-for-word/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 19:47:20 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://esmithy.net/2007/12/31/paste-special-macro-for-word/</guid>
		<description><![CDATA[I sometimes wonder how often the default paste operation in an application is appropriate. Maybe I&#8217;m abnormal (maybe?) but it seems like 73.2% of the time, I want pasted text to match the formatting of where it is going rather than where it came from. I guess the exception is when I&#8217;m copying and pasting from [...]]]></description>
			<content:encoded><![CDATA[<p>I sometimes wonder how often the default paste operation in an application is appropriate. Maybe I&#8217;m abnormal (maybe?) but it seems like 73.2% of the time, I want pasted text to match the formatting of where it is going rather than where it came from. I guess the exception is when I&#8217;m copying and pasting from within the same document. The result is that I use &#8220;Paste Special&#8221; a lot.</p>
<p><span id="more-122"></span></p>
<p>The trouble with Paste Special is that it (a) doesn&#8217;t have a keyboard shortcut and (b) brings up a dialog that has to be dealt with when all I really want is to paste as &#8220;Unformatted Text&#8221;.</p>
<p>My wife is currently a &#8220;Knowledge Bowl&#8221; coach, and one of her jobs is to put together a study guide of science vocabulary. That involves a lot of copying from various sources and pasting into the study guide (which is a Word document), and finally drove me to come up with a solution. I found something similar to the following very short macro at <a href="http://swest.wordpress.com/2006/01/15/ms-word-paste-plain-text/">http://swest.wordpress.com/2006/01/15/ms-word-paste-plain-text/</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> PasteSpecialUnformatted()
Selection.PasteAndFormat (wdFormatPlainText)
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<p>You can add this to Normal.dot by clicking the <strong>Macros</strong> button on Word 2007&#8242;s <strong>View</strong> tab.</p>
<p>Then I customized Word to bind the macro to Ctrl+Shift+V. In Word 2007, you do this by clicking the Office Menu, then <strong>Word Options</strong>, select the <strong>Customize</strong> category, click the <strong>Customize&#8230;</strong> button by <strong>Keyboard shortucts</strong>, which finally brings up the <strong>Customize Keyboard</strong> dialog. Pick Macros from the <strong>Categories</strong> list to see the macro, then you can associate a new shortcut key.</p>
]]></content:encoded>
			<wfw:commentRss>http://esmithy.net/2007/12/31/paste-special-macro-for-word/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Temporary CommandBar Customizations in Word</title>
		<link>http://esmithy.net/2007/09/04/temporary-commandbar-customizations-in-word/</link>
		<comments>http://esmithy.net/2007/09/04/temporary-commandbar-customizations-in-word/#comments</comments>
		<pubDate>Tue, 04 Sep 2007 23:00:52 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Office]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://esmithy.net/2007/09/04/temporary-commandbar-customizations-in-word/</guid>
		<description><![CDATA[It&#8217;s common for an Office add-in to put some custom menu items or toolbar buttons in the UI of the hosting application. The method to call to do this is CommandBars.Add. It is also typical that you&#8217;d like those customizations to appear so long as the add-in gets loaded, but not appear if it doesn&#8217;t. If [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s common for an Office add-in to put some custom menu items or toolbar buttons in the UI of the hosting application. The method to call to do this is <a href="http://msdn2.microsoft.com/de-de/library/microsoft.office.core.commandbarcontrols.add(VS.80).aspx">CommandBars.Add</a>. It is also typical that you&#8217;d like those customizations to appear so long as the add-in gets loaded, but not appear if it doesn&#8217;t. If your add-in gets uninstalled, for example, you clearly don&#8217;t want left-over customizations littering the application. For this reason, the Add method&#8217;s final parameter is a boolean that indicates whether a particular added control should be added temporarily. The documentation describes the parameter like this:</p>
<blockquote><dl>
<dt>Temporary </dt>
<dd>Optional <strong>Object</strong>. <strong>True</strong> to make the new control temporary. Temporary controls are automatically deleted when the container application is closed. The default value is <strong>False</strong>.</dd>
</dl>
</blockquote>
<p>This looks perfect. You can add the customizations at startup, and they&#8217;ll be gone at shutdown&#8230; except that it doesn&#8217;t work in Word.<br />
<span id="more-110"></span></p>
<p>There is a <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;212616">support article </a>that acknowledges this, but it is not a <em>bug</em> in Word. Instead, as I read the article, it is functionality not deemed worthy of Word, given its vastly superior customization capabilities.</p>
<p>By default, Word adds any customizations to the Normal.dot template, which causes a couple of problems:</p>
<ol>
<li>Those customizations are persistent, so the goal of having the customizations go away is foiled.</li>
<li>You tend to get these confusing prompts where the user is asked whether to save changes to Normal.dot, when most users don&#8217;t have a clue what Normal.dot even is.</li>
</ol>
<p>I&#8217;ve tried a few different approaches to get the temporary functionality in Word similar to how it is documented (and implemented by other Office applications like Excel and PowerPoint). One approach is to add all the customizations at add-in startup, and (since the temporary flag doesn&#8217;t do it for you) remove them all again at add-in shutdown. This mostly works, but you have to be kind of careful. If the application crashed for some reason, missing the add-in shutdown step, you need to check for your customizations before adding them again or you&#8217;ll get duplicates. Also, Normal.dot needs saving every time the application exits. It&#8217;s not a huge problem &#8212; the little progress bar goes pretty fast &#8212; but it is slightly annoying.</p>
<p>Among several others that I tried, the approach that I finally settled on takes advantage of the Word application object&#8217;s CustomizationContext property, which lets you send CommandBar customizations to a template other than Normal.dot.</p>
<p>Here are the basic steps:</p>
<ol>
<li>Embed an empty Word document template (.dot file) as a resource in the add-in. Maybe there&#8217;s a way to create a .dot programmatically from scratch, but embedding an already created one is pretty easy.</li>
<li>On start-up, if the template isn&#8217;t already on disk, extract the resource to disk in the user&#8217;s template directory (which is retrievable from the Options object using wdUserTemplatesPath).</li>
<li>Load the template by adding it to the application&#8217;s AddIns collection.</li>
<li>Before doing CommandBar customizations, set the CustomizationContext to be this template.</li>
<li>After doing customizations, <em>set the Saved property of the template to true</em>.</li>
</ol>
<p>The last step is the key. Since Word thinks that the template isn&#8217;t dirty, it doesn&#8217;t save it, and any customizations it contained will be automatically discarded when the application exits. If your add-in doesn&#8217;t get loaded ever again, the customization template will never be loaded, and would be empty even if it was.</p>
<p>I&#8217;ve found this approach to be simple; you don&#8217;t have to check for existing customizations at startup or remove anything at shutdown. No templates need to be saved, and I stopped getting random bug reports of lingering customizations or Normal.dot save prompts.</p>
]]></content:encoded>
			<wfw:commentRss>http://esmithy.net/2007/09/04/temporary-commandbar-customizations-in-word/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Office Open XML Deep Dive</title>
		<link>http://esmithy.net/2007/06/28/office-open-xml-deep-dive/</link>
		<comments>http://esmithy.net/2007/06/28/office-open-xml-deep-dive/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 23:35:58 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://esmithy.net/2007/06/28/office-open-xml-deep-dive/</guid>
		<description><![CDATA[Last week I went to San Francisco to take a dive off the deep end into the new XML file formats in Microsoft Office 2007. The training was hosted by MindJet, and presented by Doug Mahugh of Microsoft, and Chris Predeek, a consultant who put together the code samples for the hands-on labs. NextPage has been involved in [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I went to San Francisco to take a dive off the deep end into the new XML file formats in Microsoft Office 2007. The training was hosted by MindJet, and presented by <a title="Doug Mahugh" href="http://blogs.msdn.com/dmahugh/">Doug Mahugh</a> of Microsoft, and <a title="Chris Predeek" href="http://predeekc.spaces.live.com/">Chris Predeek</a>, a consultant who put together the code samples for the hands-on labs.</p>
<p><span id="more-99"></span>NextPage has been involved in the standardization process for Open XML, with our very own <a title="Dr. Ngo" href="http://www.nextpage.com/about/bios/tom.htm">Tom Ngo </a>serving on the Ecma committee. Doug, at a post-training session dinner (thanks <a title="Erick Watson" href="http://erickwa.spaces.live.com/">Erick</a>!) had only good things to say about Tom. He said that he wished Tom could be at all the committee meetings because he&#8217;s able to reason from neutral ground, whereas a Microsoft representative saying the same things would immediately be treated with skepticism and mistrust.</p>
<p>The training focused mainly on document generation independent of Office applications. This included some general XML programming with .NET and using the System.IO.Packaging API included in .NET 3.0, which I had heard of but had never seen used. The packaging API give a little higher level of abstraction than just working with the raw ZIP and XML. I also learned that there is <a href="http://openxmldeveloper.org/archive/2007/06/06/1640.aspx">yet another API </a>in the works that is at an even higher level of abstraction. It is currently in CTP form, and Doug indicated that the developers would <em>really</em> like feedback on it. Chris also showed using XSLT to generate documents from templates.</p>
<p>Aside from general understanding of our implementation domain, we&#8217;re not extremely interested in document generation at NextPage. Our efforts are more toward tracking documents that others create. There may be opportunities to store our tracking metadata as a custom XML part, whereas we currently mash some XML into the structured storage custom properties for the previous binary format.</p>
<p>Something that made the training experience unique was that it was all professionally videotaped. I don&#8217;t just mean that there was a camcorder running in the back of the room. They had multiple cameras, extensive lighting, a control room, and lots of other stuff completely lost on me as a TV production ignoramus.</p>
<p>Doug&#8217;s <a href="http://blogs.msdn.com/dmahugh/archive/2007/06/22/san-francisco-workshop.aspx">blog has a photo</a> showing all the extra lighting added for the cameras. That&#8217;s the back of my balding head in the front row, second from the right. I&#8217;ve always heard that the best students sit toward the front to the side, so I was looking for someone up there to copy off of. I&#8217;m hoping there isn&#8217;t much footage of me nodding off, what with the late-night travel to get there and the limited personal relevance of some of the material.</p>
<p>The film crew also did interviews with the various attendees of the training, which I agreed to participate in mostly for the interesting experience of being formally interviewed on camera. My willingness was nearly offset by my fear that I would say something incredibly stupid. I&#8217;m fairly sure that I said stuff at least moderately stupid. This is why I prefer writing a blog instead of doing some sort of podcast. Hopefully the producer will have a goal of making the attendees appear insightful and articulate and omit my interview altogether.</p>
]]></content:encoded>
			<wfw:commentRss>http://esmithy.net/2007/06/28/office-open-xml-deep-dive/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding an Item to the Office Menu&#8217;s &#8220;Save As&#8221; Group</title>
		<link>http://esmithy.net/2007/01/03/adding-an-item-to-the-office-menus-save-as-group/</link>
		<comments>http://esmithy.net/2007/01/03/adding-an-item-to-the-office-menus-save-as-group/#comments</comments>
		<pubDate>Thu, 04 Jan 2007 00:00:00 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://esmithy.net/wp/?p=73</guid>
		<description><![CDATA[The documentation around Office 2007 ribbon customization is still a bit sparse. I&#8217;ve been trying to add a new entry under the Save As menu in the Office Menu, and after a fair amount of trial and error, I found a way to do that. Here is the XML: &#60;!-- version=&#34;1.0&#34; encoding=&#34;utf-8--&#62; &#60;customui xmlns=&#34;http://schemas.microsoft.com/office/2006/01/customui&#34;&#62;&#60;/customui&#62; &#60;ribbon&#62;&#60;/ribbon&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The documentation around Office 2007 ribbon customization is still a bit sparse. I&#8217;ve been trying to add a new entry under the Save As menu in the Office Menu, and after a fair amount of trial and error, I found a way to do that.<span id="more-73"></span></p>
<p>Here is the XML:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- version=&quot;1.0&quot; encoding=&quot;utf-8--&gt;</span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;customui</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/office/2006/01/customui&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/customui<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ribbon<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/ribbon<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;officemenu<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/officemenu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;splitbutton</span> <span style="color: #000066;">idMso</span>=<span style="color: #ff0000;">&quot;FileSaveAsMenu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/splitbutton<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;menu</span> <span style="color: #000066;">idMso</span>=<span style="color: #ff0000;">&quot;FileSaveAsMenu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
&nbsp;
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;MyCustomButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/button<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>              label=&quot;My Custom Command&quot; 
              description=&quot;This text shows up under the label&quot; 
              imageMso=&quot;HappyFace&quot; 
              onAction=&quot;ControlClicked&quot;/&gt; 
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/menu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The odd part, in my inexperienced view, is referencing the same &#8220;FileSaveAsMenu&#8221; id in both the splitButton and the menu elements.</p>
<p>I searched in vain for an XML file that contains the definition of the complete default ribbon. Having that would have made this and other customizations much easier. A similar strategy ought to work for other pop-up style items, like Print, Prepare, Send, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://esmithy.net/2007/01/03/adding-an-item-to-the-office-menus-save-as-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
