Posts

Showing posts with the label COM Interop

Donate

How To Enable Add COM Reference In A .NET Core Application Using Visual Studio 2019

Image
Hello, When creating a project using Visual Studio 2019 like for example a Console App and you might want to reference a certain COM library, you might wonder why the Add COM Reference is not found on the context menu when you right clicked the project. This usually happens if you perform a fresh install of the Visual Studio 2019 IDE on your machine. So to enable the Add COM Reference, simply follow the steps below: 1. Upgrade VS 2019 to latest version. As of now, the latest update is version 16.8.6. 2. Set the Target framework of your console app to .NET Core 3.0. But I recommend .NET Core 3.1     framework. 3. Right click on the console app project or the Dependencies. You should be able to see Add COM Reference from the context menu. 4. Search for a COM Libary. Ex. Microsoft Excel 16.0 Object Library. 5. Add to your Project. That's it!

Get Microsoft Excel Cell Value Using C# And Office.Interop.Excel

Hello, In this article, I'll show you two options to get the cell value of excel using C#. Given that you are using VSTO and have referenced the assembly Microsoft.Office.Interop.Excel. 1 2 3 var cellValue = ( string )(xlWorkSheet.Cells[3, 6] as Excel.Range).Value2; //or this var cellValue = xlWorkSheet.get_Range( "F3" , Type.Missing).Value2; Note: xlWorkSheet is an Excel Worksheet object.

Donate