{"id":1206,"date":"2015-09-25T21:23:04","date_gmt":"2015-09-25T21:23:04","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=1206"},"modified":"2022-02-03T11:24:36","modified_gmt":"2022-02-03T17:24:36","slug":"excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/","title":{"rendered":"Excel Add-in (VSTO) using Visual Studio Community 2015 &#8211; a few hitches to get around"},"content":{"rendered":"<p>Well, this is exciting because I have for years always wanted to use Visual Studio to build my apps in Excel. I am using Office 2010 (my client uses 2010) I am beyond a VBA junkie and there is little or nothing I can&#8217;t do. However being able to add to a .net class etc. has always been missing. Also I wanted to see how hard it is or not to develop in VS. Using the VBA editor and being able to debug on the fly saves SOOOO much time. But long macros TAKE SOOOOO much time to. Can things be sped up? Is it that hard to edit\/debug? I never knew &#8211; now I will. The template for VS 2015 Office apps is meant for Office 2013+ but I got it to work for 2010 &#8211; see the humorous adventure below.<\/p>\n<p>Here are some tips along the way ( I have had some snags already &#8211; hence this post)&#8230;<!--more-->Installation &#8211; first, in VS 2012\/2013 you would click a button upon install \u00a0to include the VSTO tools for Office you could never add it after the fact except for a re-install. <a href=\"http:\/\/stackoverflow.com\/questions\/31570661\/vsto-outlook-add-ins-and-visual-studio-2015\" target=\"_blank\" rel=\"noopener noreferrer\">These guys pointed to a link that was the key for VS 2015<\/a>\u00a0(and <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/bb398242.aspx\" target=\"_blank\" rel=\"noopener noreferrer\">this link<\/a>). Below are the relevant bits<span style=\"color: #999999;\"> (I usually don&#8217;t do this but I had to wade through that to get links that said visualstudio.com or microsoft.com &#8211; I don&#8217;t trust the other links because I don&#8217;t know the source or downloads from them.).<\/span><\/p>\n<p><a href=\"https:\/\/www.visualstudio.com\/features\/office-tools-vs\" target=\"_blank\" rel=\"noopener noreferrer\">Here is the software that you run AFTER installing VS 2015.<\/a><\/p>\n<p>Here is a Microsoft article &#8220;<a href=\"https:\/\/www.visualstudio.com\/features\/office-tools-vs\" target=\"_blank\" rel=\"noopener noreferrer\">my first Application-Level Add in For Excel<\/a>&#8220;. Hey! There &#8211; I can type code! Lets go&#8230; READ THE NEXT STEPS! Good stuff and inspiration of what you can do with an add-in, ribbons etc. and <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/bb772100(v=vs.120).aspx#Publish\" target=\"_blank\" rel=\"noopener noreferrer\">deployment<\/a>. Normally I make a hidden read-only\u00a0excel .xlsm file on the network that a button would point to so many people can use it at once while I could improve or make new additions at the same time. These are works-in-progress in an engineering department &#8211; lots of changes and improvements on the fly for a small group of us.<\/p>\n<p>Lets do a hello world popup just before we save. This is like the demo but a little different.<\/p>\n<p>But alas &#8211; no luck yet <strong><span style=\"color: #ff0000;\">(UPDATE: I gave up and went to edit some more VBA and when I clicked &#8220;Save&#8221; &#8211; THE CODE BELOW IS WORKING!!!!!!! So it works, it jsut cant start Excel. I have a couple other articles &#8211; <span style=\"color: #339966;\">keep reading past &#8220;I give up for now&#8221;<\/span>)<\/span><\/strong>. It complains that I don&#8217;t have the correct version of Excel installed. \u00a0After some more digging and clicking the Help button from Visual Studio (hey &#8211; ONE help button worked from a Microsoft app and was useful!) it suggested I install <a href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=48217\" target=\"_blank\" rel=\"noopener noreferrer\">Visual Studio 2010 Tools for Office Runtime<\/a> (click for download link). I had to quick SQL and IE (good thing I am writing this in Chrome). I give up for now&#8230;. I got it working in VBA as expected <span style=\"color: #999999;\">(what can&#8217;t you do in VBA \ud83d\ude42 )<\/span><\/p>\n<p>NO NO &#8211; Stop! I don&#8217;t give up after I gave up and commenced VBA programming it showed &#8220;Hello World&#8221; in a popup\u00a0and in the lower left.\u00a0&#8230; Do these steps before you click &#8220;run&#8221;<\/p>\n<ol>\n<li>Click &#8220;Project-&gt;Project Properties&#8230;&#8221;<\/li>\n<li>Click the debug tab<\/li>\n<li>click on the radio button &#8220;Start external program&#8221;\n<ol>\n<li>type in\u00a0C:\\Program Files\\Microsoft Office\\Office14\\EXCEL.EXE (remember I am using Office 2010 64 bit)<\/li>\n<\/ol>\n<\/li>\n<li>You MIGHT need to change your Reference to point to Excel 2010 instead of 2013. I did &#8211; and it worked but I don&#8217;t know\u00a0if you have to (leave a comment if you don&#8217;t have to do this)\n<ol>\n<li>in VS, right CLick your References (in your Solution Browser Tab)<\/li>\n<li>Click Add Reference<\/li>\n<li>in the Assemblies &gt; Extensions remove the checkmark besideMicrosoft.Office.Interop.Excel \u00a0 \u00a0 \u00a0 15.0.0.0\n<p>and choose (click to left)<\/p>\n<p>Microsoft.Office.Interop.Excel \u00a0 \u00a0 \u00a014.0.0.0<\/li>\n<li>Click OK<\/li>\n<\/ol>\n<\/li>\n<li>Click run or the play button<span style=\"color: #999999;\"><a href=\"http:\/\/blogs.msdn.com\/b\/vsto\/archive\/2008\/03\/20\/developing-an-add-in-for-multiple-versions-of-office.aspx\" target=\"_blank\" rel=\"noopener noreferrer\"><br \/>\n(here is the blog article from 2008 that gave me the hint to try this 8 years later &#8230; wow 2008 and it applies!)<\/a><\/span><\/li>\n<\/ol>\n<p>Then delete or &#8220;Clean Code&#8221; as this app is REALLY annoying when you are using excel (this sentence\u00a0was added much later than this article was written)<\/p>\n<p>Here is my code.<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/\/ add this at the top\r\nusing System.Windows.Forms;\r\n\r\n\r\n\r\n\/\/ add this into the ThisAddIn_Startup method\r\n\r\n \/\/from the sample website\r\n this.Application.WorkbookBeforeSave += new Microsoft.Office.Interop.Excel.AppEvents_WorkbookBeforeSaveEventHandler(Application_WorkbookBeforeSave);\r\n\r\n if (this.Application.Version == &quot;12.0&quot;)\r\n { \r\n \/\/ 2010-specific code.\r\n }\r\n else\r\n {\r\n \/\/ 2013\/2016-specific code.\r\n }\r\n\r\n\r\n\/\/add this as the last method (a new one)\r\n void Application_WorkbookBeforeSave(Microsoft.Office.Interop.Excel.Workbook Wb, bool SaveAsUI, ref bool Cancel)\r\n {\r\n Wb.Application.StatusBar = &quot;Hello World from the status bar&quot;;\r\n DialogResult msg = MessageBox.Show(&quot;Hello World&quot;, &quot;Just For Fun&quot;, MessageBoxButtons.OKCancel, MessageBoxIcon.Stop); \r\n if (msg == DialogResult.Cancel)\r\n {\r\n Cancel = true;\r\n }\r\n }\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Continuing on &#8230;<\/p>\n<p>http:\/\/stackoverflow.com\/questions\/6923095\/how-to-create-a-button-to-call-my-vsto-add-in<\/p>\n<p>http:\/\/www.mrexcel.com\/forum\/excel-questions\/639478-how-can-i-call-vsto-vbulletin-net-functions-visual-basic-applications.html<\/p>\n<p>I think VSTO adds functionalities to your workbook and worksheets &#8211; so VSTO would add the buttons to the sheet and\/or toolbar etc.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well, this is exciting because I have for years always wanted to use Visual Studio to build my apps in Excel. I am using Office 2010 (my client uses 2010) I am beyond a VBA junkie and there is little or nothing I can&#8217;t do. However being able to add to a .net class etc. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1206","post","type-post","status-publish","format-standard","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Excel Add-in (VSTO) using Visual Studio Community 2015 - a few hitches to get around - ELB Solutions.com Inc.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Excel Add-in (VSTO) using Visual Studio Community 2015 - a few hitches to get around - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"Well, this is exciting because I have for years always wanted to use Visual Studio to build my apps in Excel. I am using Office 2010 (my client uses 2010) I am beyond a VBA junkie and there is little or nothing I can&#8217;t do. However being able to add to a .net class etc. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2015-09-25T21:23:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:24:36+00:00\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"Excel Add-in (VSTO) using Visual Studio Community 2015 &#8211; a few hitches to get around\",\"datePublished\":\"2015-09-25T21:23:04+00:00\",\"dateModified\":\"2022-02-03T17:24:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\\\/\"},\"wordCount\":878,\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\\\/\",\"name\":\"Excel Add-in (VSTO) using Visual Studio Community 2015 - a few hitches to get around - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"datePublished\":\"2015-09-25T21:23:04+00:00\",\"dateModified\":\"2022-02-03T17:24:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel Add-in (VSTO) using Visual Studio Community 2015 &#8211; a few hitches to get around\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Excel Add-in (VSTO) using Visual Studio Community 2015 - a few hitches to get around - ELB Solutions.com Inc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/","og_locale":"en_US","og_type":"article","og_title":"Excel Add-in (VSTO) using Visual Studio Community 2015 - a few hitches to get around - ELB Solutions.com Inc.","og_description":"Well, this is exciting because I have for years always wanted to use Visual Studio to build my apps in Excel. I am using Office 2010 (my client uses 2010) I am beyond a VBA junkie and there is little or nothing I can&#8217;t do. However being able to add to a .net class etc. [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2015-09-25T21:23:04+00:00","article_modified_time":"2022-02-03T17:24:36+00:00","author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"Excel Add-in (VSTO) using Visual Studio Community 2015 &#8211; a few hitches to get around","datePublished":"2015-09-25T21:23:04+00:00","dateModified":"2022-02-03T17:24:36+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/"},"wordCount":878,"articleSection":["General"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/","url":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/","name":"Excel Add-in (VSTO) using Visual Studio Community 2015 - a few hitches to get around - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"datePublished":"2015-09-25T21:23:04+00:00","dateModified":"2022-02-03T17:24:36+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/excel-add-in-vsto-using-visual-studio-community-2015-a-few-hitches-to-get-around\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"Excel Add-in (VSTO) using Visual Studio Community 2015 &#8211; a few hitches to get around"}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=1206"}],"version-history":[{"count":14,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1206\/revisions"}],"predecessor-version":[{"id":2728,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1206\/revisions\/2728"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=1206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=1206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=1206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}