<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Office Development with Visual Studio : add-ins</title><link>http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx</link><description>Tags: add-ins</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Office 2010 Application Compatibility Program (Beth Massi)</title><link>http://blogs.msdn.com/vsto/archive/2009/10/28/office-2010-application-compatibility-program-beth-massi.aspx</link><pubDate>Wed, 28 Oct 2009 16:46:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9914177</guid><dc:creator>VSTO Team</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9914177.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9914177</wfw:commentRss><description>&lt;p&gt;If you missed it, &lt;a href="http://blogs.technet.com/gray_knowlton/archive/2009/10/22/announcing-the-office-2010-application-compatibility-program.aspx" target="_blank"&gt;Office announced a compatibility program&lt;/a&gt; to help IT and developers who have built add-ins make a seamless upgrade to Office 2010.&amp;#160; We want you to have a successful and seamless migration to Office 2010 for your VSTO solutions. The program provides tools for environment assessment, code scanning and remediation assistance, and an update to the document conversion tools introduced with Office 2007. &lt;/p&gt;  &lt;p&gt;Check out &lt;a href="http://blogs.technet.com/gray_knowlton/archive/2009/10/22/announcing-the-office-2010-application-compatibility-program.aspx" target="_blank"&gt;Michael Kiselman’s post for more details on the program&lt;/a&gt; that will be available in early December. &lt;/p&gt;  &lt;p&gt;Enjoy,   &lt;br /&gt;-&lt;a href="http://blogs.msdn.com/bethmassi" target="_blank"&gt;Beth Massi&lt;/a&gt;, Visual Studio Community&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9914177" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/Beth+Massi/default.aspx">Beth Massi</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Visual Studio 2010: Specify advanced publishing options (Saurabh Bhatia)</title><link>http://blogs.msdn.com/vsto/archive/2009/10/19/visual-studio-2010-specify-advanced-publishing-options-saurabh-bhatia.aspx</link><pubDate>Mon, 19 Oct 2009 22:31:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9909491</guid><dc:creator>VSTO Team</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9909491.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9909491</wfw:commentRss><description>&lt;p&gt;I have previously &lt;a href="http://blogs.msdn.com/vsto/archive/2008/06/11/specify-a-product-name-publisher-name-and-other-properties-for-vsto-solutions-saurabh-bhatia.aspx"&gt;posted&lt;/a&gt; how you can specify various properties for a VSTO solution like the Publisher and Product Names by tweaking a few files in Visual Studio 2008.&lt;/p&gt;  &lt;p&gt;With Visual Studio 2010 (&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Beta 2&lt;/a&gt;) you can edit these properties directly through the Publish Page. All Office projects in Visual Studio 2010 now have an &lt;strong&gt;Options&lt;/strong&gt; button on the Publish Page, which allows you to spet these properties.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/VisualStudio2010Beta2Specifyadvancedpubl_128C7/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/VisualStudio2010Beta2Specifyadvancedpubl_128C7/image_thumb.png" width="555" height="387" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The Publish Options dialog is similar to the ClickOnce publish options dialog for other types of projects, but this dialog only displays the options applicable to Office projects.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/VisualStudio2010Beta2Specifyadvancedpubl_128C7/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/VisualStudio2010Beta2Specifyadvancedpubl_128C7/image_thumb_1.png" width="591" height="337" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here is what these properties mean:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Publisher Name&lt;/b&gt; – The name of the Publisher as displayed in Programs and Features&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Product Name&lt;/b&gt; – The name of the Solution as it will show up in the Programs and Features (Add Remove Programs Entry)&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Support URL&lt;/b&gt; – A URL which End Users can visit to get support for this particular solution. The support URL shows up as a clickable link for the product name during the installation trust prompt.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/VisualStudio2010Beta2Specifyadvancedpubl_128C7/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/VisualStudio2010Beta2Specifyadvancedpubl_128C7/image_thumb_2.png" width="591" height="338" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Solution Name&lt;/b&gt; – (Friendly Name) This is the name of the Add-In as it is displayed in the Office Add-ins dialog. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Office Application Description&lt;/b&gt; – The description of the Office Add-in as displayed in the Office Add-ins dialog.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Add-in Load Behavior – &lt;/strong&gt;Specifies whether the add-in should load when the Office Application Starts up or whether it should load on demand when the end user tries to interact with it. By default all add-ins are set to load at startup of the Office Application but if you care about Office startup performance and don’t want your add-in to be running all the time then you should consider loading it on demand.&lt;/p&gt;  &lt;p&gt;Andrew Whitechapel has a &lt;a href="http://blogs.msdn.com/andreww/archive/2008/07/14/demand-loading-vsto-add-ins.aspx"&gt;post&lt;/a&gt; on how an Office add-in can be demand loaded using different loadbehavior values. Previously you had manually update the ClickOnce manifests with the appropriate load behavior value. With Visual Studio 2010 you can set the option to load the add-in on demand and the loadbehavior will be automatically set to 16 (&lt;a href="http://blogs.msdn.com/andreww/archive/2008/04/19/delay-loading-the-clr-in-office-add-ins.aspx"&gt;connect first time&lt;/a&gt;) –&amp;gt; Load the add-in on startup for the first time and then load on demand from then on.&lt;/p&gt;  &lt;p&gt;Loading an add-in on demand can help improve the startup performance of the Office application. It can also reduce the application’s working set as the add-in is not loaded in memory until the end user interacts with it. Setting the add-in to demand load is a good option if your add-in has UI based triggers, like a Ribbon item that the end user can interact with to load the add-in. However demand loading may not be a good option if your add-in is needs to listen to application events like opening a document etc all the time the application is running. So if your add-in doesn’t have to run all the time, then setting it to Load on Demand is a good option to consider. &lt;/p&gt;  &lt;p&gt;Lastly, there is an interesting side note for those of you who may have changed their VS 2008 based project files based on my previous post. If you updated the project file using the same property names as that mentioned in the post, you can migrate that project to VS 2010 and continue using those property values. You no longer need the custom targets file as that functionality is now directly available in the Visual Studio common targets.&lt;/p&gt;  &lt;p&gt;For more information, see &lt;a href="http://msdn.microsoft.com/en-us/library/bb608591(VS.100).aspx"&gt;Publishing Office Solutions&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Have fun with &lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Visual Studio 2010 Beta2&lt;/a&gt; and let us know your &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/category/VSPreRelease,netdevelopmentprerelease,visualstudioprerelease,vstsprerelease"&gt;feedback&lt;/a&gt;!&lt;/p&gt;  &lt;p&gt;Saurabh &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9909491" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/ClickOnce/default.aspx">ClickOnce</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Deployment/default.aspx">Deployment</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Manifest/default.aspx">Manifest</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Saurabh+Bhatia/default.aspx">Saurabh Bhatia</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Publisher+Name/default.aspx">Publisher Name</category><category domain="http://blogs.msdn.com/vsto/archive/tags/SupportUrl/default.aspx">SupportUrl</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Product+Name/default.aspx">Product Name</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Add+Remove+Programs/default.aspx">Add Remove Programs</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+Addin+Properties/default.aspx">Office Addin Properties</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Programs+and+Features/default.aspx">Programs and Features</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category></item><item><title>Community Article: Automate Common Office Tasks (Beth Massi)</title><link>http://blogs.msdn.com/vsto/archive/2009/06/25/community-article-automate-common-office-tasks-beth-massi.aspx</link><pubDate>Fri, 26 Jun 2009 02:34:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9804476</guid><dc:creator>VSTO Team</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9804476.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9804476</wfw:commentRss><description>&lt;p&gt;If you haven’t seen it yet, we’ve got &lt;a href="http://msdn.microsoft.com/en-us/vsto/dd935909.aspx" target="_blank"&gt;a new article&lt;/a&gt; from &lt;a href="https://mvp.support.microsoft.com/profile=169AE602-45EF-47E6-8868-CA3E91D0A1EE"&gt;Robert Green&lt;/a&gt; (MVP) up on the &lt;a href="http://msdn.microsoft.com/en-us/vsto/default.aspx" target="_blank"&gt;VSTO Dev Center&lt;/a&gt;. In this article, learn how you can use Visual Studio to build application-level add-ins that automate common Microsoft Office tasks. It’s a good introduction to Office development with Visual Studio so check it out!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/vsto/dd935909.aspx" target="_blank"&gt;&lt;strong&gt;Create an Application-Level Add-In to Automate Common Office Tasks&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Enjoy,   &lt;br /&gt;-&lt;a href="http://blogs.msdn.com/bethmassi" target="_blank"&gt;Beth Massi&lt;/a&gt;, Visual Studio Community&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9804476" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Beth+Massi/default.aspx">Beth Massi</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+Development/default.aspx">Office Development</category></item><item><title>Do Your Outlook UI Elements Need Counseling? - Get your Form Regions, Ribbons, and Task Panes Talking to Each Other Again (Norm Estabrook)</title><link>http://blogs.msdn.com/vsto/archive/2009/06/03/do-your-outlook-ui-elements-need-counseling-get-your-form-regions-ribbons-and-task-panes-talking-to-each-other-again-norm-estabrook.aspx</link><pubDate>Thu, 04 Jun 2009 01:30:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9693769</guid><dc:creator>VSTO Team</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9693769.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9693769</wfw:commentRss><description>&lt;p&gt;So you want to open a task pane by using a button on the Ribbon. You also want a form region that appears in an e-mail item to detect the state of a control on a custom task pane so that you can add or remove an option that appears in a Ribbon menu right? Ok, I completely made this scenario up. But at some point, somewhere along the way, you might say to yourself – how do I get to that gallery on my Ribbon from my task pane? or how do I enable the user to populate that combo box on the form region by selecting a control on the Ribbon? Well if that describes something that you are trying to do, then this post is for you. Let’s start with Ribbons. The other two (form regions and task panes) are bit more troublesome.&lt;/p&gt;  &lt;h4&gt;Ribbons&lt;/h4&gt;  &lt;p&gt;Ribbon controls are the easiest to access from other areas of your application. Assuming that your custom Ribbon is named &lt;em&gt;Ribbon1&lt;/em&gt;, here is what you do:&lt;/p&gt;  &lt;p align="left"&gt;&lt;span style="color: #2b91af"&gt;ThisRibbonCollection &lt;/span&gt;ribbonCollection =    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;Globals&lt;/span&gt;.Ribbons    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [&lt;span style="color: #2b91af"&gt;Globals&lt;/span&gt;.ThisAddIn.Application.ActiveInspector()];    &lt;br /&gt;ribbonCollection.Ribbon1.comboBox1.Text = &lt;span style="color: #a31515"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;;&lt;/p&gt;  &lt;p&gt;You can read more about this &lt;a href="http://msdn.microsoft.com/en-us/library/bb772088.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;h4&gt;Form Regions&lt;/h4&gt;  &lt;p&gt;For the VB folks, this is a snap. C# developers have to do a bit more work. That is because by default, in a C# project, the controls that you add to a form region are private. For each control that you want to access, you have to set the &lt;strong&gt;Modifiers&lt;/strong&gt; property of the control to &lt;strong&gt;Internal &lt;/strong&gt;or &lt;strong&gt;Public&lt;/strong&gt;. For example: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/OutlookUICounselingGetyourFormRegionsRib_E1EA/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/OutlookUICounselingGetyourFormRegionsRib_E1EA/image_thumb.png" width="321" height="360" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can then add code to access the control. For example, assuming that your form region is named &lt;em&gt;FormRegion1&lt;/em&gt;, you could use the following code:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;WindowFormRegionCollection &lt;/span&gt;formRegions =
    &lt;span style="color: #2b91af"&gt;Globals&lt;/span&gt;.FormRegions
        [&lt;span style="color: #2b91af"&gt;Globals&lt;/span&gt;.ThisAddIn.Application.ActiveInspector()];
formRegions.FormRegion1.textBox1.Text = &lt;span style="color: #a31515"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

&lt;p&gt;You can read more about this &lt;a href="http://msdn.microsoft.com/en-us/library/bb772084.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Custom Task Panes&lt;/h4&gt;

&lt;p&gt;Controls on task panes require the same tweaks described for form regions above.&amp;#160; Here is an example of how to get to a button on a task pane. This example makes the following assumptions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The user control of the custom task pane is named &lt;em&gt;MyUserControl&lt;/em&gt;. &lt;/li&gt;

  &lt;li&gt;The task pane is named &lt;em&gt;myCustomTaskPane&lt;/em&gt; and it is declared as public in your code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;((&lt;span style="color: #2b91af"&gt;MyUserControl&lt;/span&gt;)&lt;span style="color: #2b91af"&gt;Globals&lt;/span&gt;.ThisAddIn.myCustomTaskPane.Control).button1.Text = &lt;span style="color: #a31515"&gt;&amp;quot;It Worked&amp;quot;&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;If have not yet created a custom task pane, see &lt;a href="http://msdn.microsoft.com/en-us/library/aa942846.aspx"&gt;this topic&lt;/a&gt; and it will all make sense.&lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;As a side note, if you are adding custom task panes to Outlook Inspector windows, you have to write a bit of code to map each Inspector window with it’s own instance of a custom task pane. If you don’t do this mapping, you get all kinds of wacky issues.&amp;#160; For an example of how to do this, see the following &lt;a href="http://msdn.microsoft.com/en-us/library/bb296010.aspx"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For the sake of being thorough, here is an example of how you can access a task pane created by using the guidance in that &lt;a href="http://msdn.microsoft.com/en-us/library/bb296010.aspx"&gt;article&lt;/a&gt;.&amp;#160; &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;toggleButton1_Click(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;RibbonControlEventArgs &lt;/span&gt;e)
{
    Outlook.&lt;span style="color: #2b91af"&gt;Inspector &lt;/span&gt;inspector = (Outlook.&lt;span style="color: #2b91af"&gt;Inspector&lt;/span&gt;)e.Control.Context;
    &lt;span style="color: #2b91af"&gt;InspectorWrapper &lt;/span&gt;inspectorWrapper = &lt;span style="color: #2b91af"&gt;Globals&lt;/span&gt;.ThisAddIn.InspectorWrappers[inspector];
    &lt;span style="color: #2b91af"&gt;CustomTaskPane &lt;/span&gt;taskPane = inspectorWrapper.CustomTaskPane;
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(taskPane != &lt;span style="color: blue"&gt;null&lt;/span&gt;)
    {
        taskPane.Visible = ((&lt;span style="color: #2b91af"&gt;RibbonToggleButton&lt;/span&gt;)sender).Checked;
        taskPane.DockPosition = Microsoft.Office.Core.&lt;span style="color: #2b91af"&gt;MsoCTPDockPosition&lt;/span&gt;.msoCTPDockPositionBottom;
        taskPane.Height = 475;
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;

&lt;p&gt;Norm E.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9693769" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/Outlook+2007/default.aspx">Outlook 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Norm+Estabrook/default.aspx">Norm Estabrook</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Ribbon/default.aspx">Ribbon</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2007/default.aspx">Office 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+Development/default.aspx">Office Development</category></item><item><title>Here is a Way to Get the ID of a Built-in Outlook Command Bar Menu (Norm Estabrook)</title><link>http://blogs.msdn.com/vsto/archive/2009/04/30/here-is-a-way-to-get-the-id-of-a-built-in-outlook-command-bar-menu-norm-estabrook.aspx</link><pubDate>Fri, 01 May 2009 00:09:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9581289</guid><dc:creator>VSTO Team</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9581289.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9581289</wfw:commentRss><description>&lt;p&gt;Recently, a &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/adee1998-d619-4667-b08c-5038d02c3a0b/?prof=required"&gt;forum poster&lt;/a&gt; asked us how he could add a submenu item to a built-in menu item in Outlook.&amp;#160; Note that these are not controls that appear on the Ribbon of an Outlook item, but rather the menus that drop down from the top of the Outlook Explorer such as the &lt;strong&gt;View&lt;/strong&gt; menu and the &lt;strong&gt;Tools&lt;/strong&gt; menu.&lt;/p&gt;  &lt;p&gt;So one way to do this (In fact the only way that I know of) is to use the example shown in the following MSDN topic - &lt;a href="http://msdn.microsoft.com/en-us/library/ms269110.aspx"&gt;How to: Add Custom Menus and Menu Items to Outlook&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;You can’t just use the example as is. You will need to add a line of code to get a handle to a built-in menu. The following example gets a handle to the &lt;strong&gt;Junk E-Mail&lt;/strong&gt; menu that appears off of the &lt;strong&gt;Actions&lt;/strong&gt; menu of the Outlook Explorer window.&lt;/p&gt;  &lt;p&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarPopup &lt;/span&gt;junkEmailMenu = (Office.&lt;span style="color: #2b91af"&gt;CommandBarPopup&lt;/span&gt;)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.Application.ActiveExplorer().CommandBars.FindControl    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; (Office.&lt;span style="color: #2b91af"&gt;MsoControlType&lt;/span&gt;.msoControlPopup, &lt;strong&gt;31353&lt;/strong&gt;, missing, missing);&lt;/p&gt;  &lt;p&gt;Note the ID number shown in the second parameter to the FindControl method. How on earth did I know that the &lt;strong&gt;Junk E-Mail&lt;/strong&gt; menu is the &lt;strong&gt;31353&lt;/strong&gt; menu?&amp;#160; The answer is … Not very easily. In fact to obtain that ID, I wrote a small Outlook add-in that iterates through all menus in Outlook and prints out their corresponding codes.&amp;#160; I figured that I would share this with you in case you ever have a similar scenario.&lt;/p&gt;  &lt;p&gt;Two notes about the sample below: First - this is a C# example, so my apologies to VB’ers. Second - this example is meant to be used in a Visual Studio 2008 Outlook (2007 or 2003) add-in project.&amp;#160; These projects automatically include the appropriate using statements that enable you to use the prefix “Office” in place of “Microsoft.Office.Core” when referring to some objects etc.&lt;/p&gt;  &lt;p&gt;Ok. Here is the code:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public partial class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ThisAddIn
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;private void &lt;/span&gt;ThisAddIn_Startup(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, System.&lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
    {
        Outlook.&lt;span style="color: #2b91af"&gt;Application &lt;/span&gt;app = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Application;
        &lt;span style="color: green"&gt;//Create a new txt file to record controls' list

        &lt;/span&gt;System.IO.&lt;span style="color: #2b91af"&gt;StreamWriter &lt;/span&gt;sw = System.IO.&lt;span style="color: #2b91af"&gt;File&lt;/span&gt;.CreateText
            (&lt;span style="color: #a31515"&gt;@&amp;quot;C:\Outlook Menus.txt&amp;quot;&lt;/span&gt;);

        &lt;span style="color: green"&gt;//loop through Outlook ActiveExplorer CommandBars to get all CommandBars

        &lt;/span&gt;&lt;span style="color: blue"&gt;foreach &lt;/span&gt;(Office.&lt;span style="color: #2b91af"&gt;CommandBarControl &lt;/span&gt;cb &lt;span style="color: blue"&gt;in &lt;/span&gt;app.ActiveExplorer().CommandBars.ActiveMenuBar.Controls)
        {
            PrintMenuItems(cb, sw);
        }

        sw.Close();

    }

    &lt;span style="color: green"&gt;// Recursive method for printing menus and nested menus.
    // Either the menu is a commandbarpopup (contains submenus)
    // Or it is a commandbarbutton (contains no submenus)

    &lt;/span&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;PrintMenuItems(&lt;span style="color: blue"&gt;object &lt;/span&gt;menuItem, System.IO.&lt;span style="color: #2b91af"&gt;StreamWriter &lt;/span&gt;sw)
    {
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(menuItem &lt;span style="color: blue"&gt;as &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarButton &lt;/span&gt;== &lt;span style="color: blue"&gt;null&lt;/span&gt;)
        {
            &lt;span style="color: green"&gt;// This is a menu bar popup control.
            &lt;/span&gt;sw.WriteLine((menuItem &lt;span style="color: blue"&gt;as &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarPopup&lt;/span&gt;).Caption +
                &lt;span style="color: #a31515"&gt;&amp;quot;\t&amp;quot; &lt;/span&gt;+ (menuItem &lt;span style="color: blue"&gt;as &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarPopup&lt;/span&gt;).Id.ToString());

            &lt;span style="color: blue"&gt;if &lt;/span&gt;((menuItem &lt;span style="color: blue"&gt;as &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarPopup&lt;/span&gt;).accChildCount &amp;gt; 0)
            {
                &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;j = 1; j &amp;lt;= (menuItem &lt;span style="color: blue"&gt;as &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarPopup&lt;/span&gt;).accChildCount; j++)
                {
                    PrintMenuItems((menuItem &lt;span style="color: blue"&gt;as &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarPopup&lt;/span&gt;).get_accChild(j), sw);
                }
            }
        }
        &lt;span style="color: blue"&gt;else
        &lt;/span&gt;{
            &lt;span style="color: green"&gt;// Must be a command
            &lt;/span&gt;sw.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;\t&amp;quot; &lt;/span&gt;+ (menuItem &lt;span style="color: blue"&gt;as &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarControl&lt;/span&gt;).Caption +
                &lt;span style="color: #a31515"&gt;&amp;quot;\t&amp;quot; &lt;/span&gt;+ (menuItem &lt;span style="color: blue"&gt;as &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarControl&lt;/span&gt;).Id.ToString());
        }

    }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;

&lt;p&gt;Norm E.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9581289" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/Outlook+2007/default.aspx">Outlook 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Norm+Estabrook/default.aspx">Norm Estabrook</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Command+bars/default.aspx">Command bars</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2007/default.aspx">Office 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2003/default.aspx">Office 2003</category><category domain="http://blogs.msdn.com/vsto/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+Development/default.aspx">Office Development</category></item><item><title>My Word Add-In Creates Duplicate Menu Items. Make it Stop! (Norm Estabrook)</title><link>http://blogs.msdn.com/vsto/archive/2009/03/06/my-word-add-in-creates-duplicate-menu-items-make-it-stop-norm-estabrook.aspx</link><pubDate>Fri, 06 Mar 2009 20:33:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9463406</guid><dc:creator>VSTO Team</dc:creator><slash:comments>13</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9463406.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9463406</wfw:commentRss><description>&lt;p&gt;So I want my add-in to place a custom command into the shortcut menu. The shortcut menu is that cool menu that appears when you right-click a document. Great, so I read some articles in MSDN, write some code, run the add-in and voila there it is! I give it to my buddy, he is proud of my accomplishment and and installs my add-in.&amp;#160; Now he hates me because every time he opens up Word, a duplicate menu appears.&amp;#160; Where did I go wrong? &lt;/p&gt;  &lt;p&gt;Well actually, I didn’t do anything wrong.&amp;#160; It’s just that Word requires a little more attention when it comes to handling menus. I guess you can say that Word is a bit more “needy” than other Office applications. But being “higher maintenance” does not have to mean “higher maintenance costs”.&amp;#160; Hopefully this post will get your friend talking to you again.&lt;/p&gt;  &lt;h3&gt;My code&lt;/h3&gt;  &lt;p&gt;Here is the code that did not work for me.&amp;#160; BTW – I will paste in both &lt;font color="#808080"&gt;Visual Basic&lt;/font&gt; and &lt;font color="#808080"&gt;C#&lt;/font&gt; examples for this post.&lt;/p&gt;  &lt;p&gt;&lt;font color="#808080"&gt;[Visual Basic]&lt;/font&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Private &lt;/span&gt;MyApplication &lt;span style="color: blue"&gt;As &lt;/span&gt;Word.Application
&lt;span style="color: blue"&gt;Private WithEvents &lt;/span&gt;myControl &lt;span style="color: blue"&gt;As &lt;/span&gt;Office.CommandBarButton

&lt;span style="color: blue"&gt;Private Sub &lt;/span&gt;ThisAddIn_Startup _
(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As Object&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;System.EventArgs) &lt;span style="color: blue"&gt;Handles Me&lt;/span&gt;.Startup

    MyApplication = &lt;span style="color: blue"&gt;Me&lt;/span&gt;.Application
    AddMenuItem()

&lt;span style="color: blue"&gt;End Sub

Private Sub &lt;/span&gt;AddMenuItem()

    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;menuItem &lt;span style="color: blue"&gt;As &lt;/span&gt;Office.MsoControlType = _
        Office.MsoControlType.msoControlButton

    myControl = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(MyApplication.CommandBars(&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;).Controls.Add _
       (menuItem, 1, &lt;span style="color: blue"&gt;True&lt;/span&gt;), Office.CommandBarButton)

    myControl.Style = Office.MsoButtonStyle.msoButtonCaption
    myControl.Caption = &lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item&amp;quot;
    &lt;/span&gt;myControl.Tag = &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;

&lt;/span&gt;&lt;span style="color: blue"&gt;End Sub


Sub &lt;/span&gt;myControl_Click(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;Ctrl &lt;span style="color: blue"&gt;As &lt;/span&gt;Microsoft.Office.Core.CommandBarButton, _
                    &lt;span style="color: blue"&gt;ByRef &lt;/span&gt;CancelDefault &lt;span style="color: blue"&gt;As Boolean&lt;/span&gt;) &lt;span style="color: blue"&gt;Handles &lt;/span&gt;myControl.Click

    System.Windows.Forms.MessageBox.Show(&lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item clicked&amp;quot;&lt;/span&gt;)

&lt;span style="color: blue"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;font color="#808080"&gt;[C#]&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private &lt;/span&gt;Word.&lt;span style="color: #2b91af"&gt;Application &lt;/span&gt;myApplication;
&lt;span style="color: blue"&gt;private &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarButton &lt;/span&gt;myControl;

&lt;span style="color: blue"&gt;private void &lt;/span&gt;ThisAddIn_Startup(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, System.&lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
{
    myApplication = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Application;
    AddMenuItem(); 
}
 
&lt;span style="color: blue"&gt;private void &lt;/span&gt;AddMenuItem()
{
   Office.&lt;span style="color: #2b91af"&gt;MsoControlType &lt;/span&gt;menuItem = 
        Office.&lt;span style="color: #2b91af"&gt;MsoControlType&lt;/span&gt;.msoControlButton;

    myControl = 
        (Office.&lt;span style="color: #2b91af"&gt;CommandBarButton&lt;/span&gt;)myApplication.CommandBars[&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;].Controls.Add
        (menuItem,missing, missing, 1, &lt;span style="color: blue"&gt;true&lt;/span&gt;);

    myControl.Style = Office.&lt;span style="color: #2b91af"&gt;MsoButtonStyle&lt;/span&gt;.msoButtonCaption;
    myControl.Caption = &lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item&amp;quot;&lt;/span&gt;;
    myControl.Tag = &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;&lt;/span&gt;;

    myControl.Click += 
        &lt;span style="color: blue"&gt;new &lt;/span&gt;Microsoft.Office.Core.&lt;span style="color: #2b91af"&gt;_CommandBarButtonEvents_ClickEventHandler
            &lt;/span&gt;(myControl_Click);

}

&lt;span style="color: blue"&gt;void &lt;/span&gt;myControl_Click(Microsoft.Office.Core.&lt;span style="color: #2b91af"&gt;CommandBarButton &lt;/span&gt;Ctrl, 
    &lt;span style="color: blue"&gt;ref bool &lt;/span&gt;CancelDefault)
{
    System.Windows.Forms.&lt;span style="color: #2b91af"&gt;MessageBox&lt;/span&gt;.Show(&lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item clicked&amp;quot;&lt;/span&gt;);
}&lt;/pre&gt;

&lt;h3&gt;Why my code does not work as expected&lt;/h3&gt;

&lt;p&gt;Here is one issue I can see right off the bat. Note this line of code for adding a control:&lt;/p&gt;

&lt;p&gt;myControl = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(MyApplication.CommandBars(&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;).Controls.Add _ (menuItem, 1, &lt;span style="color: blue"&gt;True&lt;/span&gt;), Office.CommandBarButton) &lt;/p&gt;

&lt;p&gt;I set the last parameter of the &lt;strong&gt;Add &lt;/strong&gt;method to &lt;strong&gt;True&lt;/strong&gt;.&amp;#160; This value specifies that I want my control to be temporary. I am trying to tell Word &lt;strong&gt;not&lt;/strong&gt; to save the control so that duplicate menu items won’t be added every time Word opens.&amp;#160; Only there is a problem here.&amp;#160; Word &lt;strong&gt;ignores&lt;/strong&gt; this parameter (at least for controls in a CommandBar collection anyway). So I can keep it set to &lt;strong&gt;true&lt;/strong&gt;, but it really means &lt;strong&gt;false&lt;/strong&gt;. Lovely.&lt;/p&gt;

&lt;p&gt;So what is happening? Well, Word is actually saving your new menu command to the Normal.dot template every time a new instance of Word opens – hence the duplicates.&lt;/p&gt;

&lt;h3&gt;What can I do about this?&lt;/h3&gt;

&lt;p&gt;There are probably a billion creative ways to stop the duplicate menus from appearing, but here are &lt;u&gt;three&lt;/u&gt; tips that work really well. Here they are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Check for duplicates &lt;strong&gt;before &lt;/strong&gt;adding an item (control) to a menu. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Always&lt;/strong&gt; set the customization context of the application to the same document or template before adding or deleting a control. &lt;/li&gt;

  &lt;li&gt;Because there are no temporary commands in Word, &lt;strong&gt;use a custom template&lt;/strong&gt; to save the commands. &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Tip # 1: Check for Duplicates:&lt;/h4&gt;

&lt;p&gt;This one is pretty easy.&amp;#160; Just add code to your add-in that looks for a control that has the same &lt;strong&gt;tag&lt;/strong&gt; as the control you are about to add.&amp;#160; If one exists, perform one of the following actions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Don’t add the control (It is already there). &lt;/li&gt;

  &lt;li&gt;Delete the control. Then you can add it. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I modified my code to &lt;strong&gt;delete&lt;/strong&gt; the control. Here is my code.&lt;/p&gt;

&lt;p&gt;&lt;font color="#808080"&gt;[Visual Basic]&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Private Sub &lt;/span&gt;RemoveExistingMenuItem()

    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;contextMenu &lt;span style="color: blue"&gt;As &lt;/span&gt;Office.CommandBar = _
    MyApplication.CommandBars(&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;)

    MyApplication.CustomizationContext = customTemplate

    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;control &lt;span style="color: blue"&gt;As &lt;/span&gt;Office.CommandBarButton = contextMenu.FindControl _
        (Office.MsoControlType.msoControlButton, System.Type.Missing, _
         &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;True&lt;/span&gt;, &lt;span style="color: blue"&gt;True&lt;/span&gt;)

    &lt;span style="color: blue"&gt;If Not &lt;/span&gt;(control &lt;span style="color: blue"&gt;Is Nothing&lt;/span&gt;) &lt;span style="color: blue"&gt;Then
        &lt;/span&gt;control.Delete(&lt;span style="color: blue"&gt;True&lt;/span&gt;)
    &lt;span style="color: blue"&gt;End If

End Sub&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;font color="#808080"&gt;[C#]&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;RemoveExistingMenuItem()
{
    Office.&lt;span style="color: #2b91af"&gt;CommandBar &lt;/span&gt;contextMenu = myApplication.CommandBars[&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;];
    myApplication.CustomizationContext = customTemplate;

    Office.&lt;span style="color: #2b91af"&gt;CommandBarButton &lt;/span&gt;control = 
        (Office.&lt;span style="color: #2b91af"&gt;CommandBarButton&lt;/span&gt;)contextMenu.FindControl
        (Office.&lt;span style="color: #2b91af"&gt;MsoControlType&lt;/span&gt;.msoControlButton, missing,
        &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;true&lt;/span&gt;, &lt;span style="color: blue"&gt;true&lt;/span&gt;);

    &lt;span style="color: blue"&gt;if &lt;/span&gt;((control != &lt;span style="color: blue"&gt;null&lt;/span&gt;))
    {
        control.Delete(&lt;span style="color: blue"&gt;true&lt;/span&gt;);
    }

}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h4&gt;Tip #2: Set the Customization Context&lt;/h4&gt;

&lt;p&gt;The customization context of the application tells Word where to save your customizations. To specify the customization context, set the &lt;a href="http://msdn.microsoft.com/en-us/library/aa205536(office.10).aspx"&gt;CustomizationContext&lt;/a&gt; property of the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._application(VS.80).aspx"&gt;Application&lt;/a&gt; object.&lt;/p&gt;

&lt;p&gt;By default, Word uses the &lt;strong&gt;Normal.dot&lt;/strong&gt; template as it’s customization context.&amp;#160; This is not reliable and can change. If you do not explicitly set the context, you might search for controls saved to one context such as a document, delete controls from another context such as a custom template and then add the control to another context such as Normal.dot.&lt;/p&gt;

&lt;p&gt;To avoid these issues, &lt;strong&gt;always &lt;/strong&gt;set the customization context of the application to the same document or template every time you search for, delete, or add controls to a menu.&lt;/p&gt;

&lt;p&gt;Note that in a Word document-level customization, it is probably best to set the customization context to the active document.&amp;#160; That way when the user uninstalls the customization, the document and the menu commands that pertain to that document disappear as expected.&lt;/p&gt;

&lt;p&gt;In Word application-level add-in, the best practice is to use a &lt;strong&gt;custom template&lt;/strong&gt; for reasons mentioned later on in this post.&lt;/p&gt;

&lt;p&gt;In the following example, I highlighted in bold the line that sets the customization context.&amp;#160; Further along in this post, I will show you where I got &lt;strong&gt;customTemplate&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;font color="#808080"&gt;[Visual Basic]&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Private Sub &lt;/span&gt;AddMenuItem()

&lt;strong&gt;    &lt;font size="4"&gt;MyApplication.CustomizationContext = customTemplate&lt;/font&gt;&lt;/strong&gt;

    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;menuItem &lt;span style="color: blue"&gt;As &lt;/span&gt;Office.MsoControlType = _
        Office.MsoControlType.msoControlButton

    myControl = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(MyApplication.CommandBars(&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;).Controls.Add _
       (menuItem, 1, &lt;span style="color: blue"&gt;True&lt;/span&gt;), Office.CommandBarButton)

    myControl.Style = Office.MsoButtonStyle.msoButtonCaption
    myControl.Caption = &lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item&amp;quot;
    &lt;/span&gt;myControl.Tag = &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;
    &lt;/span&gt;customTemplate.Saved = &lt;span style="color: blue"&gt;True
&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;    GC&lt;/span&gt;.Collect()
&lt;span style="color: blue"&gt;
End Sub&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font color="#808080"&gt;[C#]&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;AddMenuItem()
{
    &lt;font size="4"&gt;&lt;strong&gt;myApplication.CustomizationContext = customTemplate;&lt;/strong&gt;&lt;/font&gt;
    Office.&lt;span style="color: #2b91af"&gt;MsoControlType &lt;/span&gt;menuItem = 
        Office.&lt;span style="color: #2b91af"&gt;MsoControlType&lt;/span&gt;.msoControlButton;

    myControl = 
        (Office.&lt;span style="color: #2b91af"&gt;CommandBarButton&lt;/span&gt;)myApplication.CommandBars[&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;].Controls.Add
        (menuItem,missing, missing, 1, &lt;span style="color: blue"&gt;true&lt;/span&gt;);

    myControl.Style = Office.&lt;span style="color: #2b91af"&gt;MsoButtonStyle&lt;/span&gt;.msoButtonCaption;
    myControl.Caption = &lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item&amp;quot;&lt;/span&gt;;
    myControl.Tag = &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;&lt;/span&gt;;

    myControl.Click += 
        &lt;span style="color: blue"&gt;new &lt;/span&gt;Microsoft.Office.Core.&lt;span style="color: #2b91af"&gt;_CommandBarButtonEvents_ClickEventHandler
            &lt;/span&gt;(myControl_Click);

    customTemplate.Saved = &lt;span style="color: blue"&gt;true&lt;/span&gt;;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;    GC&lt;/span&gt;.Collect();&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;pre class="code"&gt;}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;strong&gt;Also – a quick tip&lt;/strong&gt; – set the &lt;strong&gt;Saved&lt;/strong&gt; property of the template to &lt;strong&gt;true &lt;/strong&gt;after you add the control.&amp;#160; This stops that annoying prompt from appearing that asks if you would like to save your customizations to the template.&lt;/p&gt;

&lt;h4&gt;Tip #3: Use a Custom Template&lt;/h4&gt;

&lt;p&gt;It is very difficult to delete a control &lt;strong&gt;before&lt;/strong&gt; the add-in shuts down.&amp;#160; For example, if you attempt to delete a control in the &lt;strong&gt;ThisAddIn_Shutdown&lt;/strong&gt; event handler, you will receive a not so helpful COM exception.&amp;#160; You will get similar results in the &lt;strong&gt;Quit&lt;/strong&gt; event of Word.&amp;#160; &lt;/p&gt;

&lt;p&gt;That is because the template that you are using as your application’s customization context is not writable in either of those event handlers.&amp;#160; So if you cannot easily delete the control when Word closes, that means that the control will always live inside of the template.&lt;/p&gt;

&lt;p&gt;This is a problem if you are using Normal.dot to persist the controls.&amp;#160; Here is why.&amp;#160; Let’s say the user decides that he does not want to see your command in a menu anymore.&amp;#160; With a caption such as “My Menu Item”, can you really blame him? So the user uninstalls your add-in. However, the menu command still lives in Normal.dot! When that user opens his document in Word, &amp;quot;My Menu Item” still appears. Doooh! Here comes the support calls!&lt;/p&gt;

&lt;p&gt;The way around this is to provide your own custom template to store customizations such as custom menus and menu items.&amp;#160; Your setup application can remove the template along with add-in. That way when the user uninstalls the add-in, they also remove the template that contains the menu items. &lt;/p&gt;

&lt;p&gt;In the following example, I retrieve a custom template from the users documents folder. Yes, your setup application will probably use a different location to place the custom template, but this is just for an example.&lt;/p&gt;

&lt;p&gt;&lt;font color="#808080"&gt;[Visual Basic]&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Private Sub &lt;/span&gt;GetCustomTemplate()&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;    Dim &lt;/span&gt;TemplatePath &lt;span style="color: blue"&gt;As String &lt;/span&gt;= &lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.GetFolderPath _
        (&lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;SpecialFolder&lt;/span&gt;.MyDocuments) + &lt;span style="color: #a31515"&gt;&amp;quot;\MyCustomTemplate.dotx&amp;quot;
&lt;/span&gt;&lt;span style="color: blue"&gt;    Dim &lt;/span&gt;install &lt;span style="color: blue"&gt;As Boolean &lt;/span&gt;= &lt;span style="color: blue"&gt;True

    For Each &lt;/span&gt;installedTemplate &lt;span style="color: blue"&gt;As &lt;/span&gt;Word.&lt;span style="color: #2b91af"&gt;Template &lt;/span&gt;&lt;span style="color: blue"&gt;In &lt;/span&gt;MyApplication.Templates
        &lt;span style="color: blue"&gt;If &lt;/span&gt;installedTemplate.FullName = &lt;span style="color: blue"&gt;DirectCast&lt;/span&gt;(TemplatePath, &lt;span style="color: blue"&gt;String&lt;/span&gt;) &lt;span style="color: blue"&gt;Then
            &lt;/span&gt;install = &lt;span style="color: blue"&gt;False
&lt;/span&gt;        &lt;span style="color: blue"&gt;End If
    Next

    If &lt;/span&gt;install = &lt;span style="color: blue"&gt;True Then
        &lt;/span&gt;MyApplication.AddIns.Add(TemplatePath.ToString(), &lt;span style="color: blue"&gt;True&lt;/span&gt;)
&lt;span style="color: blue"&gt;    End If

&lt;/span&gt;    customTemplate = MyApplication.Templates(TemplatePath)&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;font color="#808080"&gt;[C#]&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;GetCustomTemplate()
{
    &lt;span style="color: blue"&gt;object &lt;/span&gt;TemplatePath = &lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.GetFolderPath
        (&lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;SpecialFolder&lt;/span&gt;.MyDocuments) +
        &lt;span style="color: #a31515"&gt;&amp;quot;\\MyCustomTemplate.dotx&amp;quot;&lt;/span&gt;;
    &lt;span style="color: blue"&gt;object &lt;/span&gt;install = &lt;span style="color: blue"&gt;true&lt;/span&gt;;
    &lt;/pre&gt;

&lt;pre class="code"&gt;    &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(Word.&lt;span style="color: #2b91af"&gt;Template &lt;/span&gt;installedTemplate &lt;span style="color: blue"&gt;in &lt;/span&gt;myApplication.Templates)
    {
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(installedTemplate.FullName == (&lt;span style="color: blue"&gt;string&lt;/span&gt;)TemplatePath)
        {
            install = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
        }
    }
    &lt;span style="color: blue"&gt;if &lt;/span&gt;((&lt;span style="color: blue"&gt;bool&lt;/span&gt;)install)
    {
        myApplication.AddIns.Add(TemplatePath.ToString(), &lt;span style="color: blue"&gt;ref &lt;/span&gt;install);
    }
    customTemplate = myApplication.Templates.get_Item(&lt;span style="color: blue"&gt;ref &lt;/span&gt;TemplatePath);

}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h4&gt;&lt;font color="#808080"&gt;&lt;font color="#000000"&gt;Drum roll please .. I present the complete example&lt;/font&gt;&lt;/font&gt;&lt;/h4&gt;

&lt;p&gt;To provide context, here is the complete sample:&lt;/p&gt;

&lt;p&gt;&lt;font color="#808080"&gt;[Visual Basic]&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Public Class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ThisAddIn

    &lt;/span&gt;&lt;span style="color: blue"&gt;Private &lt;/span&gt;MyApplication &lt;span style="color: blue"&gt;As &lt;/span&gt;Word.Application
    &lt;span style="color: blue"&gt;Private WithEvents &lt;/span&gt;myControl &lt;span style="color: blue"&gt;As &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarButton
    &lt;/span&gt;&lt;span style="color: blue"&gt;Private &lt;/span&gt;customTemplate &lt;span style="color: blue"&gt;As &lt;/span&gt;Word.&lt;span style="color: #2b91af"&gt;Template

    &lt;/span&gt;&lt;span style="color: blue"&gt;Private Sub &lt;/span&gt;ThisAddIn_Startup _
    (&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As Object&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;System.&lt;span style="color: #2b91af"&gt;EventArgs&lt;/span&gt;) &lt;span style="color: blue"&gt;Handles Me&lt;/span&gt;.Startup

        MyApplication = &lt;span style="color: blue"&gt;Me&lt;/span&gt;.Application

        GetCustomTemplate()
        RemoveExistingMenuItem()
        AddMenuItem()

    &lt;span style="color: blue"&gt;End Sub

    Private Sub &lt;/span&gt;GetCustomTemplate()
        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;TemplatePath &lt;span style="color: blue"&gt;As String &lt;/span&gt;= &lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.GetFolderPath _
            (&lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;SpecialFolder&lt;/span&gt;.MyDocuments) + &lt;span style="color: #a31515"&gt;&amp;quot;\MyCustomTemplate.dotx&amp;quot;
        &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;install &lt;span style="color: blue"&gt;As Boolean &lt;/span&gt;= &lt;span style="color: blue"&gt;True

        For Each &lt;/span&gt;installedTemplate &lt;span style="color: blue"&gt;As &lt;/span&gt;Word.&lt;span style="color: #2b91af"&gt;Template &lt;/span&gt;&lt;span style="color: blue"&gt;In &lt;/span&gt;MyApplication.Templates
            &lt;span style="color: blue"&gt;If &lt;/span&gt;installedTemplate.FullName = &lt;span style="color: blue"&gt;DirectCast&lt;/span&gt;(TemplatePath, &lt;span style="color: blue"&gt;String&lt;/span&gt;) &lt;span style="color: blue"&gt;Then
                &lt;/span&gt;install = &lt;span style="color: blue"&gt;False
            End If
        Next

        If &lt;/span&gt;install = &lt;span style="color: blue"&gt;True Then
            &lt;/span&gt;MyApplication.AddIns.Add(TemplatePath.ToString(), &lt;span style="color: blue"&gt;True&lt;/span&gt;)
        &lt;span style="color: blue"&gt;End If

        &lt;/span&gt;customTemplate = MyApplication.Templates(TemplatePath)

    &lt;span style="color: blue"&gt;End Sub

    Private Sub &lt;/span&gt;RemoveExistingMenuItem()

        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;contextMenu &lt;span style="color: blue"&gt;As &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBar &lt;/span&gt;= _
        MyApplication.CommandBars(&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;)

        MyApplication.CustomizationContext = customTemplate

        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;control &lt;span style="color: blue"&gt;As &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarButton &lt;/span&gt;= contextMenu.FindControl _
            (Office.&lt;span style="color: #2b91af"&gt;MsoControlType&lt;/span&gt;.msoControlButton, System.&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;.Missing, _
             &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;True&lt;/span&gt;, &lt;span style="color: blue"&gt;True&lt;/span&gt;)

        &lt;span style="color: blue"&gt;If Not &lt;/span&gt;(control &lt;span style="color: blue"&gt;Is Nothing&lt;/span&gt;) &lt;span style="color: blue"&gt;Then
            &lt;/span&gt;control.Delete(&lt;span style="color: blue"&gt;True&lt;/span&gt;)
        &lt;span style="color: blue"&gt;End If

    End Sub


    Private Sub &lt;/span&gt;AddMenuItem()

        MyApplication.CustomizationContext = customTemplate

        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;menuItem &lt;span style="color: blue"&gt;As &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;MsoControlType &lt;/span&gt;= _
            Office.&lt;span style="color: #2b91af"&gt;MsoControlType&lt;/span&gt;.msoControlButton

        myControl = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(MyApplication.CommandBars(&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;).Controls.Add _
           (menuItem, 1, &lt;span style="color: blue"&gt;True&lt;/span&gt;), Office.&lt;span style="color: #2b91af"&gt;CommandBarButton&lt;/span&gt;)

        myControl.Style = Office.&lt;span style="color: #2b91af"&gt;MsoButtonStyle&lt;/span&gt;.msoButtonCaption
        myControl.Caption = &lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item&amp;quot;
        &lt;/span&gt;myControl.Tag = &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;
        &lt;/span&gt;customTemplate.Saved = &lt;span style="color: blue"&gt;True

        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;GC&lt;/span&gt;.Collect()

    &lt;span style="color: blue"&gt;End Sub

    Sub &lt;/span&gt;myControl_Click(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;Ctrl &lt;span style="color: blue"&gt;As &lt;/span&gt;Microsoft.Office.Core.&lt;span style="color: #2b91af"&gt;CommandBarButton&lt;/span&gt;, _
                        &lt;span style="color: blue"&gt;ByRef &lt;/span&gt;CancelDefault &lt;span style="color: blue"&gt;As Boolean&lt;/span&gt;) &lt;span style="color: blue"&gt;Handles &lt;/span&gt;myControl.Click

        System.Windows.Forms.&lt;span style="color: #2b91af"&gt;MessageBox&lt;/span&gt;.Show(&lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item clicked&amp;quot;&lt;/span&gt;)

    &lt;span style="color: blue"&gt;End Sub

    Private Sub &lt;/span&gt;ThisAddIn_Shutdown() &lt;span style="color: blue"&gt;Handles Me&lt;/span&gt;.Shutdown

    &lt;span style="color: blue"&gt;End Sub

End Class
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;font color="#808080"&gt;[C#]&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public partial class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ThisAddIn
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;private &lt;/span&gt;Word.&lt;span style="color: #2b91af"&gt;Application &lt;/span&gt;myApplication;
    &lt;span style="color: blue"&gt;private &lt;/span&gt;Office.&lt;span style="color: #2b91af"&gt;CommandBarButton &lt;/span&gt;myControl;
    &lt;span style="color: blue"&gt;private &lt;/span&gt;Word.&lt;span style="color: #2b91af"&gt;Template &lt;/span&gt;customTemplate;

    &lt;span style="color: blue"&gt;private void &lt;/span&gt;ThisAddIn_Startup(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, System.&lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
    {
        myApplication = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Application;

        GetCustomTemplate();
        RemoveExistingMenuItem();
        AddMenuItem();
    }

    &lt;span style="color: blue"&gt;private void &lt;/span&gt;GetCustomTemplate()
    {
        &lt;span style="color: blue"&gt;object &lt;/span&gt;TemplatePath = &lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.GetFolderPath
            (&lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;SpecialFolder&lt;/span&gt;.MyDocuments) +
            &lt;span style="color: #a31515"&gt;&amp;quot;\\MyCustomTemplate.dotx&amp;quot;&lt;/span&gt;;
        &lt;span style="color: blue"&gt;object &lt;/span&gt;install = &lt;span style="color: blue"&gt;true&lt;/span&gt;;
        &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(Word.&lt;span style="color: #2b91af"&gt;Template &lt;/span&gt;installedTemplate &lt;span style="color: blue"&gt;in &lt;/span&gt;myApplication.Templates)
        {
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(installedTemplate.FullName == (&lt;span style="color: blue"&gt;string&lt;/span&gt;)TemplatePath)
            {
                install = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
            }
        }
        &lt;span style="color: blue"&gt;if &lt;/span&gt;((&lt;span style="color: blue"&gt;bool&lt;/span&gt;)install)
        {
            myApplication.AddIns.Add(TemplatePath.ToString(), &lt;span style="color: blue"&gt;ref &lt;/span&gt;install);
        }
        customTemplate = myApplication.Templates.get_Item(&lt;span style="color: blue"&gt;ref &lt;/span&gt;TemplatePath);

    }

    &lt;span style="color: blue"&gt;private void &lt;/span&gt;RemoveExistingMenuItem()
    {
        Office.&lt;span style="color: #2b91af"&gt;CommandBar &lt;/span&gt;contextMenu = myApplication.CommandBars[&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;];
        myApplication.CustomizationContext = customTemplate;

        Office.&lt;span style="color: #2b91af"&gt;CommandBarButton &lt;/span&gt;control =
            (Office.&lt;span style="color: #2b91af"&gt;CommandBarButton&lt;/span&gt;)contextMenu.FindControl
            (Office.&lt;span style="color: #2b91af"&gt;MsoControlType&lt;/span&gt;.msoControlButton, missing,
            &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;true&lt;/span&gt;, &lt;span style="color: blue"&gt;true&lt;/span&gt;);

        &lt;span style="color: blue"&gt;if &lt;/span&gt;((control != &lt;span style="color: blue"&gt;null&lt;/span&gt;))
        {
            control.Delete(&lt;span style="color: blue"&gt;true&lt;/span&gt;);
        }

    }

    &lt;span style="color: blue"&gt;private void &lt;/span&gt;AddMenuItem()
    {
        myApplication.CustomizationContext = customTemplate;
        Office.&lt;span style="color: #2b91af"&gt;MsoControlType &lt;/span&gt;menuItem =
            Office.&lt;span style="color: #2b91af"&gt;MsoControlType&lt;/span&gt;.msoControlButton;

        myControl =
            (Office.&lt;span style="color: #2b91af"&gt;CommandBarButton&lt;/span&gt;)myApplication.CommandBars[&lt;span style="color: #a31515"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;].Controls.Add
            (menuItem, missing, missing, 1, &lt;span style="color: blue"&gt;true&lt;/span&gt;);

        myControl.Style = Office.&lt;span style="color: #2b91af"&gt;MsoButtonStyle&lt;/span&gt;.msoButtonCaption;
        myControl.Caption = &lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item&amp;quot;&lt;/span&gt;;
        myControl.Tag = &lt;span style="color: #a31515"&gt;&amp;quot;MyMenuItem&amp;quot;&lt;/span&gt;;

        myControl.Click +=
            &lt;span style="color: blue"&gt;new &lt;/span&gt;Microsoft.Office.Core.&lt;span style="color: #2b91af"&gt;_CommandBarButtonEvents_ClickEventHandler
                &lt;/span&gt;(myControl_Click);

        customTemplate.Saved = &lt;span style="color: blue"&gt;true&lt;/span&gt;;

        &lt;span style="color: #2b91af"&gt;GC&lt;/span&gt;.Collect();

    }

    &lt;span style="color: blue"&gt;void &lt;/span&gt;myControl_Click(Microsoft.Office.Core.&lt;span style="color: #2b91af"&gt;CommandBarButton &lt;/span&gt;Ctrl,
        &lt;span style="color: blue"&gt;ref bool &lt;/span&gt;CancelDefault)
    {
        System.Windows.Forms.&lt;span style="color: #2b91af"&gt;MessageBox&lt;/span&gt;.Show(&lt;span style="color: #a31515"&gt;&amp;quot;My Menu Item clicked&amp;quot;&lt;/span&gt;);
    }
    &lt;span style="color: blue"&gt;private void &lt;/span&gt;ThisAddIn_Shutdown(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, System.&lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
    {
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Now you can issue a patch to your buddy so that he has only one “My Menu Item” appearing in his shortcut menu.&amp;#160; Although .. I am not sure what “My Menu Item” is really suppose to do … 

&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9463406" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/Norm+Estabrook/default.aspx">Norm Estabrook</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Command+bars/default.aspx">Command bars</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2007/default.aspx">Office 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2003/default.aspx">Office 2003</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Word+2007/default.aspx">Word 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Word+2003/default.aspx">Word 2003</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+14/default.aspx">Office 14</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Deploying Office 2003 Solutions with Windows Installer (Mary Lee)</title><link>http://blogs.msdn.com/vsto/archive/2008/12/17/deploying-office-2003-solutions-with-windows-installer-mary-lee.aspx</link><pubDate>Thu, 18 Dec 2008 02:08:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9232290</guid><dc:creator>VSTO Team</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9232290.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9232290</wfw:commentRss><description>&lt;p&gt;You may want to develop Microsoft Office 2003 solutions with Visual Studio Tools for Office (VSTO) in Visual Studio 2008 SP1 for several reasons.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Your customers are using Microsoft Office 2003.&lt;/li&gt;    &lt;li&gt;Your customers are using both Microsoft Office 2003 and the 2007 Microsoft Office system.&lt;/li&gt;    &lt;li&gt;Your customers are using .NET Framework 2.0 and cannot migrate to .NET Framework 3.5.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Once you're done with development, you'll want to deploy your Microsoft Office 2003 solutions to your end users. This process involves the following steps:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Check for and install the following prerequisites: .NET FX 2.0, VSTO 2005 SE runtime, and the Microsoft Office primary interop assemblies.&amp;#160; If your client computers already have the prerequisites, or you want to do this manually, you can skip this step.&lt;/li&gt;    &lt;li&gt;Copy the customization assembly to the end user computer.&lt;/li&gt;    &lt;li&gt;Grant full trust to the customization assembly.&lt;/li&gt;    &lt;li&gt;For application-level add-ins only, create a set of registry keys so that the Office application knows to load the add-in.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Due to customer demand, I've created five &lt;a href="http://code.msdn.microsoft.com/VSTO2005SEMSI"&gt;deployment samples&lt;/a&gt; that demonstrate these steps. Step 1 is demonstrated in two ways: you can select your prerequisites through the &lt;a href="http://msdn.microsoft.com/en-us/library/7tx0bw8y.aspx"&gt;Prerequisites Dialog Box&lt;/a&gt; to be installed with the Setup.exe bootstrapper; alternatively, you can configure launch conditions in the Setup project to only install the customization if the prerequisites already exist. &lt;/p&gt;  &lt;p&gt;Prerequisites Dialog Box:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_6.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="378" alt="Prerequisites Dialog Box" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_thumb_2.png" width="484" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Launch Conditions editor:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_16.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="140" alt="image" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_thumb_7.png" width="657" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can use the Setup project to complete step 2 by copying the customization assembly and for document-level projects, the document or workbook, to the designated installation location. This is done by adding the project output with the File System Editor. The default installation location in these Setup projects is %PROGRAMFILES%\MyCompany\&amp;lt;Name of Setup Project&amp;gt;.&lt;/p&gt;  &lt;p&gt;File System Editor:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_12.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="120" alt="image" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_thumb_5.png" width="663" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Full trust is granted by using the SetSecurity project for step 3. This code uses a custom action in the Setup project to create a &lt;a href="http://msdn.microsoft.com/en-us/library/930b76w0.aspx"&gt;code access security&lt;/a&gt; policy that creates a solution code group for your Office solution, and an assembly code group for the customization assembly. &lt;/p&gt;  &lt;p&gt;Custom Actions Editor:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_14.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="174" alt="image" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_thumb_6.png" width="659" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Step 4 only applies to application-level add-ins: when you use the Excel 2003 add-in or Word 2003 add-in project templates, there is a Setup project automatically added to your Office solution that already creates the registry keys documented in &lt;a href="http://msdn.microsoft.com/en-us/library/bb386106.aspx"&gt;Registry Entries for Application-Level Add-Ins&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Registry Editor:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_10.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="229" alt="image" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/DeployingOffice2003SolutionswithWindowsI_9C61/image_thumb_4.png" width="656" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The process of preparing the development computer for deployment and configuring the Setup project is written out step-by-step in the following two whitepapers:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb332051.aspx"&gt;Deploying Visual Studio 2005 Tools for the Office System SE Solutions Using Windows Installer (Part 1 of 2)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb332052.aspx"&gt;Deploying Visual Studio 2005 Tools for the Office System SE Solutions Using Windows Installer: Walkthroughs (Part 2 of 2)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, it's time to experiment on your own. &lt;strong&gt;Download the sample code&lt;/strong&gt; and the completed installers from the MSDN Code Gallery: &lt;a title="http://code.msdn.microsoft.com/VSTO2005SEMSI" href="http://code.msdn.microsoft.com/VSTO2005SEMSI"&gt;http://code.msdn.microsoft.com/VSTO2005SEMSI&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Happy deployment!&lt;/p&gt;  &lt;p&gt;Mary Lee, Programming Writer.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9232290" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Mary+Lee/default.aspx">Mary Lee</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Windows+Installer/default.aspx">Windows Installer</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2003/default.aspx">Office 2003</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Deployment/default.aspx">Deployment</category><category domain="http://blogs.msdn.com/vsto/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/vsto/archive/tags/MSI/default.aspx">MSI</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category></item><item><title>Community Article: Enabling Speech Recognition in Microsoft Word 2007 with Visual Studio 2008 (Beth Massi)</title><link>http://blogs.msdn.com/vsto/archive/2008/10/21/community-article-enabling-speech-recognition-in-microsoft-word-2007-with-visual-studio-2008-beth-massi.aspx</link><pubDate>Wed, 22 Oct 2008 01:51:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9010472</guid><dc:creator>VSTO Team</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9010472.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9010472</wfw:commentRss><description>&lt;p&gt;A &lt;a href="http://msdn.microsoft.com/en-us/library/dd148511.aspx" target="_blank"&gt;new community submitted article&lt;/a&gt; was just released on the &lt;a href="http://msdn.com/vsto" target="_blank"&gt;Office Development with Visual Studio portal&lt;/a&gt; by MVP &lt;a href="http://community.visual-basic.it/Alessandro"&gt;Alessandro Del Sole&lt;/a&gt;. &lt;a href="http://msdn.microsoft.com/en-us/library/dd148511.aspx" target="_blank"&gt;In this article&lt;/a&gt; learn how to control the Vista operating system's speech recognition engine in .NET from a custom task pane in Microsoft Word 2007. This article compliments Alessandro's &lt;a href="http://msdn.microsoft.com/en-us/library/cc627340.aspx" target="_blank"&gt;previous article on a text-to-speech add-in&lt;/a&gt; for Word 2007. &lt;/p&gt; &lt;p&gt;Enjoy,&lt;br&gt;-&lt;a href="http://blogs.msdn.com/bethmassi" target="_blank"&gt;Beth Massi&lt;/a&gt;, Visual Studio Community&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9010472" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Word+2007/default.aspx">Word 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Beth+Massi/default.aspx">Beth Massi</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category></item><item><title>Diagnosing/Troubleshooting Office Add-ins with AddInSpy (Beth Massi)</title><link>http://blogs.msdn.com/vsto/archive/2008/10/02/diagnosing-troubleshooting-office-add-ins-with-addinspy-beth-massi.aspx</link><pubDate>Fri, 03 Oct 2008 00:22:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8974439</guid><dc:creator>VSTO Team</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vsto/comments/8974439.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=8974439</wfw:commentRss><description>&lt;p&gt;If you missed the announcement on the &lt;a href="http://msdn.com/vsto" target="_blank"&gt;VSTO Developer Portal&lt;/a&gt;, the team released a tool called &lt;a href="http://msdn.microsoft.com/en-us/library/cc984533.aspx" target="_blank"&gt;AddInSpy&lt;/a&gt; that helps diagnosing problems with Office Add-ins. Andrew Whitechapel talks about it on &lt;a href="http://blogs.msdn.com/andreww/archive/2008/09/30/addinspy.aspx" target="_blank"&gt;his blog here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Also check out and download the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en" target="_blank"&gt;VSTO Power Tools&lt;/a&gt; which &lt;a href="http://blogs.msdn.com/andreww/archive/tags/VSTO+Power+Tools/default.aspx" target="_blank"&gt;Andrew&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/bethmassi/archive/2008/07/29/handy-visual-studio-add-in-to-view-office-2007-files.aspx" target="_blank"&gt;myself&lt;/a&gt;, and &lt;a href="http://blogs.msdn.com/vsto/archive/tags/VSTO+Power+Tools/default.aspx" target="_blank"&gt;the team has blogged&lt;/a&gt; about before. This &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en" target="_blank"&gt;download&lt;/a&gt; is packed with tools that make your life much easier when developing Office solutions. So if you don't have them already, what are you waiting for? Download &lt;a href="http://code.msdn.microsoft.com/AddInSpy/" target="_blank"&gt;AddInSpy&lt;/a&gt; and the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en" target="_blank"&gt;Power Tools&lt;/a&gt; now!&lt;/p&gt; &lt;p&gt;Also stay up to date with announcement, videos, downloads, etc from the team by visiting the &lt;a href="http://msdn.com/vsto" target="_blank"&gt;VSTO Developer Portal&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Enjoy,&lt;br&gt;-&lt;a href="http://blogs.msdn.com/bethmassi" target="_blank"&gt;Beth Massi&lt;/a&gt;, Visual Studio Community&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8974439" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/VSTO+Power+Tools/default.aspx">VSTO Power Tools</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Beth+Massi/default.aspx">Beth Massi</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category></item><item><title>How Do I: Deploy Application-Level Office 2007 Solutions with Windows Installer? (Mary Lee)</title><link>http://blogs.msdn.com/vsto/archive/2008/10/02/how-do-i-deploy-application-level-office-2007-solutions-with-windows-installer-mary-lee.aspx</link><pubDate>Thu, 02 Oct 2008 19:21:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8973862</guid><dc:creator>VSTO Team</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/vsto/comments/8973862.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=8973862</wfw:commentRss><description>&lt;p&gt;In &lt;a href="http://blogs.msdn.com/vsto/archive/2008/04/10/deploying-an-office-solution-using-windows-installer-mary-lee.aspx"&gt;Deploying an Office solution using Windows Installer&lt;/a&gt;, you read how to deploy application-level Office 2007 solutions with Windows Installer.&amp;#160; As a follow up, you can now &lt;em&gt;see&lt;/em&gt; how to add a Setup project to your VSTO solution and create registry keys. This example uses Excel 2007, but you can apply these principles to any application-level add-in.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/vcsharp/cc998443.aspx"&gt;Deploying Excel Application-level Add-ins with Windows Installer&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/vcsharp/cc998443.aspx"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="184" alt="MSI1" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/HowDoIDeployApplicationLevelOffice2007So_8364/MSI1_1.jpg" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This video is based on the whitepaper: &lt;a href="http://msdn.microsoft.com/en-us/library/cc563937.aspx"&gt;Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer (Part 1 of 2)&lt;/a&gt;, where you can get the code and follow along step-by-step.&lt;/p&gt;  &lt;p&gt;Mary Lee, Programming Writer.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8973862" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Mary+Lee/default.aspx">Mary Lee</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Windows+Installer/default.aspx">Windows Installer</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Excel+2007/default.aspx">Excel 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Deployment/default.aspx">Deployment</category><category domain="http://blogs.msdn.com/vsto/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/vsto/archive/tags/MSI/default.aspx">MSI</category><category domain="http://blogs.msdn.com/vsto/archive/tags/video/default.aspx">video</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category></item><item><title>Word Add-ins Part 3: Search for Text Strings in Documents and Add Comments (Harry Miller)</title><link>http://blogs.msdn.com/vsto/archive/2008/09/10/word-add-ins-part-3-search-for-text-strings-in-documents-and-add-comments-harry-miller.aspx</link><pubDate>Thu, 11 Sep 2008 00:49:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8942135</guid><dc:creator>VSTO Team</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/vsto/comments/8942135.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=8942135</wfw:commentRss><description>&lt;p&gt;You can search the text in any open Microsoft Office Word document for specific strings if you put the code in an application-level add-in. When you find an instance of the string, you can perform some action on it. This video shows how to flag the string with a comment that contains text passed in from a calling method.&lt;/p&gt;  &lt;p&gt;The code comes from the forum thread that's linked below, under &amp;quot;Related resources.&amp;quot; You could just look at it there, but then you'd miss the whole &amp;quot;why did he get knocked in the head last time&amp;quot; thing. Oh, the title is different in the video because no one would search the Web for &amp;quot;to hunt lives the add-in&amp;quot; to answer this question, but I think it's a much more dramatic title for a video about an add-in that searches for stuff, after you've already found the video.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Related resources:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=3595121&amp;amp;SiteID=1" target="_blank"&gt;Forum: Look for a string and comment it - how?&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/f1f367bx.aspx" target="_blank"&gt;How to: Search for Text in Documents&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/tf2wdd02.aspx" target="_blank"&gt;How to: Set Search Options in Word&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb211938.aspx" target="_blank"&gt;Find Object (Word 2007 Reference)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Duration: 3 minutes, 39 seconds&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:752073b7-c8ed-44ba-b2d0-12dcefafbc0a" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;div id="f57663f3-72ab-4926-8b49-22c7746d93c0" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://video.msn.com/video.aspx?vid=1a14c07f-db93-4a18-9fa4-f8387eb19691&amp;amp;from=writer" target="_new"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/WordAddinsPart3SearchforTextStringsandAd_C9ED/videod1f2fafeb726.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('f57663f3-72ab-4926-8b49-22c7746d93c0'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;embed src=\&amp;quot;http://images.video.msn.com/flash/soapbox1_1.swf\&amp;quot; quality=\&amp;quot;high\&amp;quot; width=\&amp;quot;432\&amp;quot; height=\&amp;quot;364\&amp;quot; wmode=\&amp;quot;transparent\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; pluginspage=\&amp;quot;http://macromedia.com/go/getflashplayer\&amp;quot; flashvars=\&amp;quot;c=v&amp;amp;v=1a14c07f-db93-4a18-9fa4-f8387eb19691&amp;amp;from=writer\&amp;quot; &amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8942135" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/Harry+Miller/default.aspx">Harry Miller</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Word+2007/default.aspx">Word 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/video/default.aspx">video</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category></item><item><title>Word Add-ins Part 2: When Add-ins Collide (Harry Miller)</title><link>http://blogs.msdn.com/vsto/archive/2008/09/05/word-add-ins-part-2-when-add-ins-collide.aspx</link><pubDate>Fri, 05 Sep 2008 22:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8926795</guid><dc:creator>VSTO Team</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vsto/comments/8926795.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=8926795</wfw:commentRss><description>&lt;P&gt;When you build an add-in project, it installs the add-in on your development computer. Even if you close that project and start another, or even close Visual Studio entirely, all add-ins you have built will still run when you start the Office application on that computer. If you're not expecting the add-in to run, you might be surprised by what you see the next time you open the application or test a new project. This video shows how to easily uninstall add-ins from your development computer after you build them if you don't want them to run any more. Basically, you run Clean Solution, which is on the Build menu. But watch the video for proof!&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Related resources:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=3775613&amp;amp;SiteID=1" target=_blank mce_href="http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=3775613&amp;amp;SiteID=1"&gt;Forum: Multiple add-ins running&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/h2c9cdc0.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/h2c9cdc0.aspx"&gt;Office Solution Build Process Overview&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Duration: 2 minutes, 50 seconds&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:1d954864-2caf-4c46-a1b1-cac4ebf34f38 style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;
&lt;DIV id=5543d852-c00c-418a-a4d4-4d78bd69f226 style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;
&lt;DIV&gt;&lt;A href="http://video.msn.com/video.aspx?vid=cc74fdc8-b48b-4e09-b980-516583014299&amp;amp;from=writer" target=_new mce_href="http://video.msn.com/video.aspx?vid=cc74fdc8-b48b-4e09-b980-516583014299&amp;amp;from=writer"&gt;&lt;IMG alt="" src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/WordAddinsPart2WhenAddinsCollide_B2BD/videoe06f05479809.jpg" onload="var downlevelDiv = document.getElementById('5543d852-c00c-418a-a4d4-4d78bd69f226'); downlevelDiv.innerHTML = &amp;quot;&lt;div&gt;&lt;embed src=\&amp;quot;http://images.video.msn.com/flash/soapbox1_1.swf\&amp;quot; quality=\&amp;quot;high\&amp;quot; width=\&amp;quot;432\&amp;quot; height=\&amp;quot;364\&amp;quot; wmode=\&amp;quot;transparent\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; pluginspage=\&amp;quot;http://macromedia.com/go/getflashplayer\&amp;quot; flashvars=\&amp;quot;c=v&amp;amp;v=cc74fdc8-b48b-4e09-b980-516583014299&amp;amp;from=writer\&amp;quot; &gt;&lt;\/embed&gt;&lt;\/div&gt;&amp;quot;;" galleryimg="no" mce_src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/WordAddinsPart2WhenAddinsCollide_B2BD/videoe06f05479809.jpg"&gt;&lt;/A&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8926795" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/Harry+Miller/default.aspx">Harry Miller</category><category domain="http://blogs.msdn.com/vsto/archive/tags/video/default.aspx">video</category><category domain="http://blogs.msdn.com/vsto/archive/tags/build+process/default.aspx">build process</category><category domain="http://blogs.msdn.com/vsto/archive/tags/add-ins/default.aspx">add-ins</category></item></channel></rss>