CS0234: The type or namespace name ‘Office’ does not exist in the namespace ‘Microsoft’

CS0234: The type or namespace name ‘Office’ does not exist in the namespace ‘Microsoft’

The issue in Visual Studio by executing the following code using the following lines:

using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;

Solution: Need to install Microsoft.Office.Interop.Excel package.

  1. Go to the Reference button in the Right side window of solution explorer:

2. Right-click on the References button and select the NuGet Packages as shown below:

3. It will open the new window, you will click on Browse Button and go to Search: type “EXCEL” and go for search as shown below:

4. Install Microsoft.Office.Interop.Exec by selecting it for download as below screen appears:

5. After download, it will remove the errors on build it again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.