Interop.Excel.Application is not defined

Hi,

I’ve tried importing the Microsoft.Office.Interop.Excel namespace, then within an Invoke code activity putting the following:
Dim xl As Microsoft.Office.Interop.Excel.Application

However, I get the following error message:

Main has thrown an exception

Source: Invoke code

Message: Error compiling code
error BC30002: Type ‘Microsoft.Office.Interop.Excel.Application’ is not defined. At line 1

Exception Type: ArgumentException

System.ArgumentException: Error compiling code
error BC30002: Type ‘Microsoft.Office.Interop.Excel.Application’ is not defined. At line 1

But Intellisense in Invoke Method window gives Microsoft.Office.Interop.Excel.Application namespace.

Did something solve this problem?

Thank you.

4 Likes

I am also curious about this.

Hi Alex,

Were you able to solve the issue? thanks

Do you have the below assembly in your xaml, if not add it manually and restart your project and try again.

image

11 Likes

Thank you very much, after adding this line UiPath could find the reference.

Hi Guys, I fixed that, as vvaidya mentioned, but have still the same issue: error BC30002: Type ‘Microsoft.Office.Interop.Excel.Application’ is not defined. At line 1

Before this fix, there was an error: Cannot find the interop type that matches the embedded type ‘microsoft.office.interop.excel.application’… Any Idea? Thanks.

Check if “Microsoft.Office.Interop.Excel” is not automatically added

xmlns:moie=“clr-namespace:Microsoft.Office.Interop.Excel;assembly=Microsoft.Office.Interop.Excel”

1 Like

yes. adding the above assembly reference, workflow works fine. But when I edit the workflow in studio, this manually added reference getting deleted all the time. Please help.

1 Like

This works for me. Just wondering why this entry is not automatically entered by UiPath Studio in the xaml file.

Just hit this issue myself using Microsoft.Office.Interop.Outlook.

If I add the import using the UiPath UI (lower pane) then the reference is not added. I need to manually add the reference two places in the xaml file. Then after I make any edits to the invoke code section the xaml is overwritten and references are lost again.

xmlns:moie="clr-namespace:Microsoft.Office.Interop.Outlook;assembly=Microsoft.Office.Interop.Outlook”

Seems like an unpleasant bug and makes it almost impossible to import these references.

The thread is also unanswered in this thread
https://forum.uipath.com/t/how-to-set-the-name-space-and-assembly-references-for-uipath-file/22188/11

Hi @bobpeers ,

Has this been resolved to your knowledge?

Hi @bradsterling,
I wish I could help but to be honest I haven’t tried this in quite a while so I have no idea if it’s still an issue.

@bobpeers - thanks for the response.

FYI for all others - I got around it by using ClosedXML.

1 Like

Hello, I am also trying to use this namespace, however, I cannot declare variables with type of Microsoft.Office.Interop.Excel.Range.Row, could you please help?

@bobpeers
Please add a new variable to the Workflow of the type (Microsoft.Office.Interop.Outlook).

Guys, I have added assembly reference and done this

xmlns:moie="clr-namespace:Microsoft.Office.Interop.Excel;assembly=Microsoft.Office.Interop.Excel”

still facing this error, any inputs to resolve this issue

Hi @msangha80

Welcome back! :slight_smile:

Could you try these two topics and see if the solutions from there will help?
https://forum.uipath.com/search?q=%22BC31539%22%20status%3Asolved

Both will have a post that is marked as a solution.

If there is a paraticular assembly/namespace you would like to use, try checking if it is provided as nuget.
For this particular case, you can add the assembly from package manager by adding www.nuget.org as one of your nuget feed.
https://api.nuget.org/v3/index.json” is the source value.

2 Likes