Fastest way to interface between live (unsaved) Excel data and C# objects

I’ll take this as a challenge, and will bet the fastest way to shuffle your data between Excel and C# is to use Excel-DNA – http://excel-dna.net. (Disclaimer: I develop Excel-DNA. But it’s still true…) Because it uses the native .xll interface it skips all the COM integration overhead that you’d have with VSTO or another … Read more

How can I create a (VSTO) Office 2007 add-in using VS 2012?

You can get VS 2012 working with Office 2007. First create an Outlook 2010 Add-In and modify the project file (.csproj) so that it will open in Office 2007 and not look for Office 2010 when run. Here is the project settings change (Outlook example): Source XPath: //Project/ProjectExtensions/VisualStudio/FlavorProperties/ProjectProperties/@DebugInfoExeName Old Value (Office 2010): DebugInfoExeName=”#Software\Microsoft\Office\14.0\Outlook\InstallRoot\Path#outlook.exe” New Value … Read more

How to unit test Excel VBA code

Disclaimer: I own Rubberduck’s GitHub repository, and I’m one of the devs involved in the project. Rubberduck is under active development. It’s much more than a unit testing tool for VBA though, but it works pretty well and lets you write VBA unit tests pretty much without any boilerplate: ‘@TestModule Private Assert As New Rubberduck.AssertClass … Read more

Installing Office Customization

You can try to delete a registry key located at: HKEY_CURRENT_USER\Software\Microsoft\VSTA\Solutions\{GUID} The value of {GUID} will be different on your environment. Check to ensure that you’re deleting the right key. Confirm by checking the DWORD “Url” value at the key. Restart Excel and you should be good to go.

Beginning VSTO Development

Yeah, it can get confusing, especially given the skip-level naming conventions, etc. Essentially, you’ll need: Full version (not Express) of Visual Studio and the .NET version you’re targetting. One of the VSTO run times (VSTO 2003, VSTO 2005, VSTO 2005 SE, VSTO 2008, VSTO 2010). For what your asking, VSTO 2005 SE is probably your … Read more

How to reference Microsoft.Office.Interop.Excel dll?

Use NuGet (VS 2013+): The easiest way in any recent version of Visual Studio is to just use the NuGet package manager. (Even VS2013, with the NuGet Package Manager for Visual Studio 2013 extension.) Right-click on “References” and choose “Manage NuGet Packages…”, then just search for Excel. VS 2012: Older versions of VS didn’t have … Read more

Excel Interop – Efficiency and performance

When using C# or VB.Net to either get or set a range, figure out what the total size of the range is, and then get one large 2 dimensional object array… //get values object[,] objectArray = shtName.get_Range(“A1:Z100”).Value2; iFace = Convert.ToInt32(objectArray[1,1]); //set values object[,] objectArray = new object[3,1] {{“A”}{“B”}{“C”}}; rngName.Value2 = objectArray; Note that its important … Read more