<?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 : Office 2010</title><link>http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx</link><description>Tags: Office 2010</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Using Office 2010 Extensibility Schemas with VSTO addins for Beta 2 (Stephen Peters)</title><link>http://blogs.msdn.com/vsto/archive/2009/12/04/using-office-2010-extensibility-schemas-with-vsto-addins-for-beta-2-stephen-peters.aspx</link><pubDate>Fri, 04 Dec 2009 22:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9932795</guid><dc:creator>VSTO Team</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9932795.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9932795</wfw:commentRss><description>&lt;P&gt;Office 2010 brings in many new features to the Ribbon and Backstage extensibility. In order to take advantage of those changes in VSTO addins, you will need to update your ribbon XML projects to use the new Office 2010 schema. &lt;/P&gt;
&lt;P&gt;First, you will need to see if the schema is installed. To do this, look in “C:\Program Files\Microsoft Visual Studio 10.0\Xml\Schemas\1033” (you might need to modify this to point to your Visual Studio installation directory). If customui14.xsd is there, you can skip ahead to the next paragraph. Otherwise download the schema from &lt;A href="http://download.microsoft.com/download/F/F/3/FF36D32F-4080-494B-83B8-49DADC68A999/Office2010FluentUISchema.exe" mce_href="http://download.microsoft.com/download/F/F/3/FF36D32F-4080-494B-83B8-49DADC68A999/Office2010FluentUISchema.exe"&gt;here&lt;/A&gt;, and install it in the directory above. When you are done, double check to make sure that the custom14ui.xsd file is there.&lt;/P&gt;
&lt;P&gt;Go to the Ribbon XML item that you want to use on Office 2010. For this blog post I am going to use a Word 2010 addin with a single Ribbon XML item, but the same code can work with any VSTO project with only minor modifications.&lt;/P&gt;
&lt;P&gt;At the top Ribbon1.xml, there is a line&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;customUI &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="http://schemas.microsoft.com/office/2006/01/customui" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;onLoad&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Ribbon_Load"&amp;gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;/SPAN&gt;
&lt;P&gt;You will want to replace the URL with&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;  http://schemas.microsoft.com/office/2009/07/customui&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;If you look in the properties window for the XML document, the schema for the document should now point to the customui14.xsd that was installed. Now we can play around with it a bit. Under &amp;lt;/ribbon&amp;gt; in Ribbon1.xml, add the following code:&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;backstage&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;tab &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="VSTOTab" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;label&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="VSTO Tab" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;insertAfterMso&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="TabInfo"&amp;gt;
      &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;firstColumn&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;group &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="VSTOGroup" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;label&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Hello From VSTO!"&amp;gt;
          &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;topItems&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;button &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="AddMoreCowbell"
              &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;label&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Add More Cowbell"
              &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;onAction&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="AddMoreCowbell" /&amp;gt;
          &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;topItems&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;group&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;firstColumn&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;tab&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;backstage&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;/SPAN&gt;
&lt;P&gt;We will also need to add the callback to Ribbon1.cs:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public void &lt;/SPAN&gt;AddMoreCowbell(Office.&lt;SPAN style="COLOR: #2b91af"&gt;IRibbonControl &lt;/SPAN&gt;control)
{
    System.Windows.Forms.&lt;SPAN style="COLOR: #2b91af"&gt;MessageBox&lt;/SPAN&gt;.Show(&lt;SPAN style="COLOR: #a31515"&gt;"Fever Cured"&lt;/SPAN&gt;);
}&lt;/PRE&gt;
&lt;P&gt;And, of course, the integration in ThisAddin.cs&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;protected override &lt;/SPAN&gt;Microsoft.Office.Core.&lt;SPAN style="COLOR: #2b91af"&gt;IRibbonExtensibility &lt;/SPAN&gt;CreateRibbonExtensibilityObject()
{
    &lt;SPAN style="COLOR: blue"&gt;return new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Ribbon1&lt;/SPAN&gt;();
}&lt;/PRE&gt;
&lt;P&gt;Run your add-in, and when you go to the backstage, you will find the backstage tab that we just added:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/UsingOffice2010ExtensibilitySchemaswithV_C281/clip_image002_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/UsingOffice2010ExtensibilitySchemaswithV_C281/clip_image002_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image002 border=0 alt=clip_image002 src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/UsingOffice2010ExtensibilitySchemaswithV_C281/clip_image002_thumb.jpg" width=244 height=193 mce_src="http://blogs.msdn.com/blogfiles/vsto/WindowsLiveWriter/UsingOffice2010ExtensibilitySchemaswithV_C281/clip_image002_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Now that you have the schemas set up, you can read up more on extending Backstage and new Ribbon features here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ee692176(office.14).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ee692176(office.14).aspx"&gt;Microsoft Office 2010 Technical Articles&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &lt;A href="http://msdn.microsoft.com/en-us/library/ee815851(office.14).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ee815851(office.14).aspx"&gt;Customizing the Office 2010 Backstage View for Developers&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - &lt;A href="http://msdn.microsoft.com/en-us/library/ee691834(office.14).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ee691834(office.14).aspx"&gt;Ribbon Extensibility in Office 2010: Tab Activation and Auto-Scaling&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://download.microsoft.com/download/F/F/3/FF36D32F-4080-494B-83B8-49DADC68A999/Office2010FluentUISchema.exe" mce_href="http://download.microsoft.com/download/F/F/3/FF36D32F-4080-494B-83B8-49DADC68A999/Office2010FluentUISchema.exe"&gt;Office 2010 Custom UI Schema&lt;/A&gt; (repost from above)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9932795" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/Ribbon/default.aspx">Ribbon</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+Development/default.aspx">Office Development</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx">Office 2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Stephen+Peters/default.aspx">Stephen Peters</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Backstage/default.aspx">Backstage</category></item><item><title>Office 2010 Beta &amp; SharePoint 2010 Beta Now Available to the Public (Beth Massi)</title><link>http://blogs.msdn.com/vsto/archive/2009/11/18/office-2010-beta-sharepoint-2010-beta-now-available-to-the-public-beth-massi.aspx</link><pubDate>Wed, 18 Nov 2009 18:54:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9924532</guid><dc:creator>VSTO Team</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9924532.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9924532</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/vsto/archive/2009/11/16/office-sharepoint-2010-betas-available-beth-massi.aspx"&gt;Monday Office and SharePoint 2010 Beta were released&lt;/a&gt; to MSDN/TechNet subscribers. Today it was announced at PDC that these are available to the rest of the public! Come and get it…&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/office/2010/" target="_blank"&gt;&lt;strong&gt;Office 2010 Beta&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sharepoint.microsoft.com/2010/" target="_blank"&gt;&lt;strong&gt;SharePoint 2010 Beta&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;These Betas are compatible with &lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" target="_blank"&gt;Visual Studio 2010 Beta 2&lt;/a&gt; which was released to the public a few weeks ago. We’ve also started a series on Channel 9 on SharePoint development in Visual Studio so check that out starting with:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/funkyonex/Overview-of-SharePoint-Development-in-Visual-Studio-2010/"&gt;&lt;strong&gt;Overview of SharePoint Development in Visual Studio 2010&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Also check out…&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Office 2010 resources&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.technet.com/office2010/archive/2009/11/16/announcing-office-2010-beta-availability.aspx"&gt;Announcing Office 2010 Beta Availability&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vsto/ee676911.aspx"&gt;Office Development in Visual Studio 2010 Beta Samples, Walkthroughs and Videos &lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/officedevelopmentprerelease/threads"&gt;Submit your feedback in the Office Development in Visual Studio 2010 Forums&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/office/ee513173.aspx"&gt;Office 2010 Beta Resources&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.technet.com/gray_knowlton/archive/2009/11/10/office-2010-application-compatibility-deep-dive-on-the-code-compatibility-inspector.aspx"&gt;Office 2010 Application Compatibility Tools&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;SharePoint 2010 Resources&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/sharepoint/archive/2009/11/18/sharepoint-2010-public-beta-is-now-available-for-download.aspx"&gt;SharePoint 2010 Public Beta is now available for download&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/sharepoint/ee513147.aspx"&gt;SharePoint 2010 Development Resources&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx#Sharepoint"&gt;SharePoint Development in Visual Studio 2010 Walkthroughs&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopmentprerelease/threads"&gt;SharePoint Development Forums&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;And stay tuned here for more posts on &lt;a href="http://blogs.msdn.com/vsto/archive/tags/VS2010/default.aspx" target="_blank"&gt;Office Development with Visual Studio 2010&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=9924532" 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/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx">Office 2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category></item><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>Channel 9 Interview: John Durant on Developing Managed Applications for Office 2010 in Visual Studio 2010 (Beth Massi)</title><link>http://blogs.msdn.com/vsto/archive/2009/09/17/channel-9-interview-john-durant-on-developing-managed-applications-for-office-2010-in-visual-studio-2010-beth-massi.aspx</link><pubDate>Thu, 17 Sep 2009 21:41:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9896451</guid><dc:creator>VSTO Team</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9896451.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9896451</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://msdn.microsoft.com/theshow" target="_blank"&gt;Robert Hess&lt;/a&gt; posted an interview yesterday on Channel 9 with &lt;a href="http://blogs.msdn.com/johnrdurant/" target="_blank"&gt;John Durant&lt;/a&gt; on &lt;a href="http://channel9.msdn.com/shows/The+Knowledge+Chamber/John-Durant--Developing-Managed-Applications-for-Office-2010-in-Visual-Studio-2010/" target="_blank"&gt;&lt;strong&gt;Developing Managed Applications for Office 2010 in Visual Studio 2010&lt;/strong&gt;&lt;/a&gt;. When you have 20 minutes you should check it out. &lt;/p&gt;  &lt;p&gt;John provides some highlights as to what he’ll be showing in his &lt;a href="http://microsoftpdc.com/Sessions/P09-06" target="_blank"&gt;PDC sessions&lt;/a&gt;, and some of the new features that developers can look forward to in Office and Visual Studio 2010.&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=9896451" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/video/default.aspx">video</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/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/vsto/archive/tags/VS2010/default.aspx">VS2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Will your VSTO addin run on Office 2010 64-bit? Yes, probably. (Christin Boyd)</title><link>http://blogs.msdn.com/vsto/archive/2009/08/05/will-your-vsto-addin-run-on-office-2010-64-bit-yes-probably-christin-boyd.aspx</link><pubDate>Thu, 06 Aug 2009 01:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9858450</guid><dc:creator>VSTO Team</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9858450.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9858450</wfw:commentRss><description>&lt;p&gt;The Visual Studio team is designing the runtime components for Office 2010 so that your Visual Studio Tools for Office 2005 and Visual Studio 2008 .NET addins, document solutions and spreadsheet solutions will run on 64-bit Office 2010.&amp;#160; These runtime components will ship with Office 2010, so your end-users won’t even have to download a new runtime!&amp;#160; How easy is that?&amp;#160; There are a few rare exceptions that I’ll discuss in this blog entry.&amp;#160; &lt;/p&gt;  &lt;p&gt;The miracle of managed code allows you to write C# or Visual Basic .NET code that compiles to “Any CPU” using the Compile setting in your Visual Studio project.&amp;#160; Your code compiles to MSIL with Visual Studio, and then at runtime it gets JIT compiled to the correct chip set, either AMD, Intel, 32-bit or 64-bit.&amp;#160; The first exception to this wondrous technology is the oldest versions of .NET Framework 1.0 and 1.1 will not enable this 64-bit transformation.&lt;/p&gt;  &lt;p&gt;The other thing to lookout for is calls to process invoke (p/invoke) in your code. If you try to call native API methods using p/invoke you could have issues with your VSTO solution running properly on 64-bit Office 2010.&amp;#160; &lt;/p&gt;  &lt;p&gt;You will have problems if your code makes deliberate calls to p/invoke a Win32 API that does not have exactly the same signature (method name, parameter list, and DLL name) of an equivalent Win64 API.&amp;#160; This is true for any solution you write regardless of targeting Office as the platform.&amp;#160; You can find a ton of information in MSDN and blogs by such luminaries as Scott Hanselman about writing Windows API calls so that they will run on either 32-bit or 64-bit Windows.&amp;#160; Here is a generalized code snippet for handling cases where the method name or the DLL name is different:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 244px; background-color: #f4f4f4; text-align: left"&gt;   &lt;pre id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;p align="left"&gt;&lt;span style="color: #008000"&gt;//YourFunction has the same name, parameters, and DLL name in 32bit and 64bit&lt;/span&gt;&lt;br /&gt;YourFunction();&lt;br /&gt;&lt;br /&gt;Import(&lt;span style="color: #006080"&gt;&amp;quot;LIBRARY&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;YOURFUNCTION&amp;quot;&lt;/span&gt;, CharSet = CharSet.Unicode)]&lt;br /&gt;private &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; YouFunction();&lt;/p&gt;&lt;p align="left"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//In some cases, the method name is different in Win32 API and Win64 API, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//so use the following code block in stead of the above 3 lines of code.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Marshal.SizeOf(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(IntPtr)) == 4)&lt;br /&gt;{&lt;br /&gt;    YourFunction32();&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Marshal.SizeOf(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(IntPtr)) == 8)&lt;br /&gt;{&lt;br /&gt;    YourFunction64();&lt;br /&gt;}&lt;/p&gt;&lt;p align="left"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Import(&lt;span style="color: #006080"&gt;&amp;quot;LIBRARY32&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;YOURFUNCTION32&amp;quot;&lt;/span&gt;, CharSet = CharSet.Unicode)]&lt;br /&gt;private &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; YourFunction32();&lt;br /&gt;&lt;br /&gt;Import(&lt;span style="color: #006080"&gt;&amp;quot;LIBRARY64&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot; YOURFUNCTION64&amp;quot;&lt;/span&gt;, CharSet = CharSet.Unicode)]&lt;br /&gt;private &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; YourFunction64();&lt;br /&gt;&lt;/p&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h3&gt;Resources:&lt;/h3&gt;

&lt;p&gt;Here are more resources to help you author your solutions today so that they will run without needing a recompile when your users install 64-bit Office 2010.&lt;/p&gt;

&lt;p&gt;MSDN Library Visual Studio 2005 article on developing &lt;a href="http://msdn.microsoft.com/en-us/library/ms241064(VS.80).aspx" target="_blank"&gt;64-bit Applications&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MSDN Library Visual Studio 2008 article on developing &lt;a href="http://msdn.microsoft.com/en-us/library/ms241064.aspx" target="_blank"&gt;64-bit Applications&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cumgranosalis/archive/2005/12/09/Win64RegistryPart1.aspx" target="_blank"&gt;How to access the “real” x64 registry from a Win32 .NET Application – Part I&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms953313.aspx" target="_blank"&gt;The Myth of .NET Purity, Reloaded&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For migrating your really old apps with lots of native calls to .NET, try checking if your native calls have an equivalent .NET call:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa302340.aspx" target="_blank"&gt;Microsoft Win32 to Microsoft .NET Framework API Map&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/sd10k43k.aspx" target="_blank"&gt;Interoperating with Unmanaged Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Finally I should mention that this is my last post (for a while at least) on this blog because I am leaving Microsoft.&amp;#160; I’m going to work on a charity project teaching robotics programming to high school kids in my “inner city” neighborhood for at least the next 6 months.&amp;#160; The project is called &lt;a href="http://www.teamxbot.org/" target="_blank"&gt;Team Xbot&lt;/a&gt;!&amp;#160; Keep an eye on these kids as they go on to good colleges and great jobs in the next few years!&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Sincerely, Christin Boyd, Program Manager&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9858450" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/runtime/default.aspx">runtime</category><category domain="http://blogs.msdn.com/vsto/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Christin+Boyd/default.aspx">Christin Boyd</category><category domain="http://blogs.msdn.com/vsto/archive/tags/primary+interop+assemblies/default.aspx">primary interop assemblies</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+Development/default.aspx">Office Development</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>Demonstrating how to sync Facebook events to Outlook</title><link>http://blogs.msdn.com/vsto/archive/2009/08/05/demonstrating-how-to-sync-facebook-events-to-outlook.aspx</link><pubDate>Wed, 05 Aug 2009 19:59:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9858214</guid><dc:creator>VSTO Team</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9858214.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9858214</wfw:commentRss><description>&lt;p&gt;Every once in a while, we learn of neat apps that have been created with the Office development tools in Visual Studio. In an Outlook 2007 add-in, Jake Ginnivan combined WPF and the Facebook API to respond to Facebook events from a Ribbon. In addition, this add-in works in Outlook 2010 and has been deployed with ClickOnce.&amp;#160; He’s written about this in two parts:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://jake.ginnivan.net/2009/07/writing-a-facebook-event-synchroniser-for-outlook-2007-part-1/"&gt;Writing a Facebook event synchroniser for Outlook 2007+ Part 1&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://jake.ginnivan.net/2009/07/writing-a-facebook-event-synchroniser-for-outlook-2007-part-2/"&gt;Writing a Facebook event synchroniser for Outlook 2007+ Part 2&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;If you have come across other VSTO apps, feel free to leave a link in a comment here.&lt;/p&gt;  &lt;p&gt;Mary Lee, Programming Writer.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9858214" 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/Office+2007/default.aspx">Office 2007</category><category domain="http://blogs.msdn.com/vsto/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>32bit Visual Studio and 64bit Office (Christin Boyd)</title><link>http://blogs.msdn.com/vsto/archive/2009/06/11/32bit-visual-studio-and-64bit-office-christin-boyd.aspx</link><pubDate>Thu, 11 Jun 2009 22:44:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9727544</guid><dc:creator>VSTO Team</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9727544.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9727544</wfw:commentRss><description>&lt;p&gt;Visual Studio 2010 will ship with a 32bit version, and no 64bit version.&amp;#160; My team built a very smart layer into Visual Studio 2010 to enable designers and debuggers that work with 64bit Office 2010 and 64bit SharePoint Server 2010.&amp;#160; &lt;/p&gt;  &lt;p&gt;For a good explanation of why the Visual Studio team chose to only build a 32bit version for the next release, you can find a blog post by Rico Mariani titled “&lt;a href="http://blogs.msdn.com/ricom/archive/2009/06/10/visual-studio-why-is-there-no-64-bit-version.aspx" target="_blank"&gt;Visual Studio: Why is there no 64 bit version? (yet)&lt;/a&gt;”&lt;/p&gt;  &lt;p&gt;SharePoint Server 2010 will be 64-bit only.&amp;#160; You can learn more about the requirements of Microsoft SharePoint Server 2010 on the SharePoint Team Blog entry “&lt;a href="http://blogs.msdn.com/sharepoint/archive/2009/05/07/announcing-sharepoint-server-2010-preliminary-system-requirements.aspx" target="_blank"&gt;Announcing SharePoint Server 2010 Preliminary System Requirements&lt;/a&gt;”&amp;#160; If you plan to build solutions for the next generation of SharePoint Server, then I recommend budgeting to purchase 64bit hardware.&lt;/p&gt;  &lt;p&gt;-Christin Boyd, Program Manager, Visual Studio&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9727544" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vsto/archive/tags/Christin+Boyd/default.aspx">Christin Boyd</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/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx">Office 2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category></item><item><title>Sign up for Office 2010 Technical Preview</title><link>http://blogs.msdn.com/vsto/archive/2009/05/12/sign-up-for-office-2010-technical-preview.aspx</link><pubDate>Tue, 12 May 2009 20:36:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9607782</guid><dc:creator>VSTO Team</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9607782.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9607782</wfw:commentRss><description>&lt;p&gt;I’m at TechEd in LA, but it seems I could get just as much excitement just watching the Twittersphere today and watching #tela09 tags!&amp;#160; And my feet are killing me.&amp;#160; So be glad you’re sitting at your computer instead of walking around Los Angeles!&amp;#160; Let me give you some highlights for Office developers:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.msteched.com/online/home.aspx" target="_blank"&gt;Watch the Keynotes&lt;/a&gt; which include Office 2010 demos.&amp;#160; Also some &lt;a href="http://www.msteched.com/online/channels.aspx?cname=track&amp;amp;channel=Office+%26+SharePoint" target="_blank"&gt;interviews on Office and SharePoint&lt;/a&gt; on the same TechEd site.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.office2010themovie.com/" target="_blank"&gt;Office 2010 The Movie:&amp;#160; Countdown to Awesome&lt;/a&gt; is the new site where you can watch a slick video and more importantly, click the Sign up for the Microsoft Office 2010 Technology Preview.&amp;#160; When you click the link they show you the “fine print” which I will now print in large font:&lt;/p&gt;  &lt;h4&gt;By registering you are signing up to be considered for the Technical Preview Program, you will be &lt;strong&gt;waitlisted for consideration to be invited&lt;/strong&gt; into the Technical Preview Program. We will notify invitees in early to mid July.&lt;/h4&gt;  &lt;p&gt;“What does that mean?” you ask.&amp;#160; Well, it means that Microsoft wants to collect a wide variety of customer-types and ensure that our TechPreview covers all the different types of customers.&amp;#160; For example, the sign-up form asks if you will test the Tech Preview at Home or Work.&amp;#160; Be honest in your answer because we truly want to get perspectives from all types of Office users.&amp;#160; Similarly the survey asks the size of your company and if you read Japanese.&amp;#160; There is no trick to get invited.&amp;#160; &lt;/p&gt;  &lt;p&gt;If you don’t get invited, then don’t fret.&amp;#160; We’ll give you some useful information on this blog and other Office blogs to help you prepare your business for the future.&amp;#160; For now, I encourage you to build great solutions for Office using all of the resources at Microsoft including Visual Studio, VBA, Open XML SDK, code samples, Forum support, Code Gallery, and the &lt;a href="http://msdn.microsoft.com/office" target="_blank"&gt;Office Developer Center&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Sincerely, Christin Boyd, Program Manager&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9607782" 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/Christin+Boyd/default.aspx">Christin Boyd</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/video/default.aspx">video</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><category domain="http://blogs.msdn.com/vsto/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Developing for Office and SharePoint Server 2010 (Christin Boyd)</title><link>http://blogs.msdn.com/vsto/archive/2009/05/01/developing-for-office-and-sharepoint-server-2010-christin-boyd.aspx</link><pubDate>Fri, 01 May 2009 23:08:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9582882</guid><dc:creator>VSTO Team</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/vsto/comments/9582882.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vsto/commentrss.aspx?PostID=9582882</wfw:commentRss><description>&lt;p&gt;I get a lot of questions about the future.&amp;#160; &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;When will Office and SharePoint release?&lt;/strong&gt;&lt;em&gt;&amp;#160; First half of 2010.&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Is VSTO part of Microsoft’s long term strategy?&lt;/strong&gt;&amp;#160; &lt;em&gt;Yes!&amp;#160; The Office tools shipped in VS 2008 and will ship in VS 2010 with lots of cool new improvements.&amp;#160; We strongly encourage and support .NET development on the Office and SharePoint platforms. &lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Will there be better Team Development tools for Office and SharePoint developers?&lt;/strong&gt;&amp;#160; &lt;em&gt;Yes!&amp;#160; Future blog posts will tell you more.&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Are there any pricing changes?&lt;/strong&gt;&amp;#160; &lt;em&gt;See below note on SharePoint Designer.&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Can I get Office 2010 Beta or SharePoint Server 2010 Beta?&lt;/strong&gt;&amp;#160; &lt;em&gt;Yes, eventually.&amp;#160; A few thousand enterprises, small businesses, developers, ISVs, Partners, schools and families have been invited to join an early private “technical preview” beta, and the rest of the world will get to test a later public beta.&amp;#160; No dates have been announced.&amp;#160; Read the &lt;/em&gt;&lt;a href="http://www.computerworld.com/action/article.do?command=printArticleBasic&amp;amp;taxonomyName=Software+Development&amp;amp;articleId=9131672&amp;amp;taxonomyId=63" target="_blank"&gt;&lt;em&gt;Computer World&lt;/em&gt;&lt;/a&gt;&lt;em&gt; article on the Office Beta.&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Should I sanitize my keyboard to prevent the H1N1 flu?&lt;/strong&gt;&amp;#160; &lt;em&gt;Yes, but don’t put it in the dishwasher like my internship roommate did after a cola spill.&amp;#160; It was hilarious, and half the keys still worked!&lt;/em&gt;&amp;#160; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In the coming months you will see a few more blog posts about the future and plenty of blog posts about developing today with Visual Studio 2008.&amp;#160; For now, I’d like to review all of the &lt;strong&gt;official&lt;/strong&gt; posts that Microsoft has released about developing SharePoint Server 2010 solutions:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/presspass/features/2009/Apr09/04-15Office2010.mspx " target="_blank"&gt;Press Release on SharePoint Server 2010&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://office.microsoft.com/en-us/sharepointdesigner/HA103607611033.aspx" target="_blank"&gt;SharePoint Designer is now FREE&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/somasegar/archive/2009/02/19/sharepoint-tools-support-in-visual-studio.aspx" target="_blank"&gt;Soma’s blog post “SharePoint tools support in Visual Studio”&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx" target="_blank"&gt;Official Visual Studio 2010 home page&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://download.microsoft.com/download/C/0/9/C0965791-049B-4200-9008-F07A783026F6/VisualStudio2010_ProductOverview.pdf " target="_blank"&gt;PDF of the Official Visual Studio 2010 Product Overview&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/VisualStudio/Sharepoint-Development-with-Visual-Studio-2010/" target="_blank"&gt;Channel9 Interview with the Lead Program Manager designing the Office and SharePoint tools in VS 2010&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If I’ve forgotten any of the official Microsoft announcements in this post, then please leave a comment with a link.&amp;#160; Thanks!&lt;/p&gt;  &lt;p&gt;-Christin Boyd, Program Manager&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9582882" 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/Christin+Boyd/default.aspx">Christin Boyd</category><category domain="http://blogs.msdn.com/vsto/archive/tags/SharePoint/default.aspx">SharePoint</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/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/Office+2010/default.aspx">Office 2010</category><category domain="http://blogs.msdn.com/vsto/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</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></channel></rss>