Nevertheless, here is the code I am trying to execute, and below that are error messages at Design time, and then at Run time. You are absolutely correct in stating that we don’t need to use the Imports feature if we are fully referencing the Interop objects.
For example, I am able to Delete Sheets from a Workbook, but if I run this code (below), there is a design time error popping up all the time. I have built an Excel Library in UiPath but I am finding that the code is not working reliably for some portions of the functionality. Word Interop Reference: Namespace | Microsoft Learn.Outlook Interop Reference: Namespace | Microsoft Learn.Excel Interop Reference: Namespace | Microsoft Learn.General info on MS Office COM Interop: Office primary interop assemblies - Visual Studio | Microsoft Learn.If any developers from UiPath have any idea on why this is case, I would be happy to know! References I do not know why this happens, but through much trial and error, I was able to narrow it down to this issue and it is reproducible on v2018.3.1. But can be any activity where the output is assigned to a variable. It does not have to be the Assign activity. So you just need to make sure there is some sort of assignment activity anywhere on your workflow. For example, the following workflow will fail with the above error:īut if you add an assign statement, it will work: There is a weird bug in UiPath where you need to have some sort of assign activity in order for the code to compile. Are you missing an assembly reference? At line 4 Are you missing an assembly reference? At line 2Įrror BC31539: Cannot find the interop type that matches the embedded type '.Application'. Are you missing an assembly reference? At line 1Įrror BC31539: Cannot find the interop type that matches the embedded type '.Workbook'. Sometimes, even after you complete the steps above, you will still get this error: Source: Invoke CodeĮrror BC31539: Cannot find the interop type that matches the embedded type '.Application'. See the References below for more information on using the MS Office COM interop objects. Write your code in the Invoke Code activity. You can substitute Excel for Outlook, Word, or any of the other supported COM Interops. When you are done it should look something like. Add the assembly reference here.įor example, if you are trying to use the Excel interop, then add. Somewhere typically around line 40, you will see all the assembly references. xaml file for your workflow using a text editor such as Notepad or Notepad++. To do so, close the workflow file in UiPath Studio. xaml file is the only way (at this time) to load the assembly references. NOTE: Modifying the xaml files directly is not supported or recommended by UiPath. To load the assembly reference, you will have to manually modify the. xaml.įor this tutorial, I’ll assume that you have not imported any namespaces. Be aware, if you add a namespace, the only way to modify or remove the import is to manually edit the. The new namespace will take effect when you reopen the workflow file. After you import a namespace, you will have to save and close the workflow file. And also, you want to avoid namespace collisions where multiple namespaces may have the same object or property names. It all depends on your coding preference.
For example, the following code snippets within the Invoke Code activity would all be equivalent:Įxample 1: No namespace imported Dim ExcelApp As .ApplicationĮxcelApp = New .ApplicationĮxample 2: namespace imported Dim ExcelApp As ApplicationĮxample 3: namespace imported Dim ExcelApp As Excel.Application Importing the namespace is helpful so you don’t have to type out the full name of the objects or properties within the namespace each time you use it. Within the sequence, put the Invoke Code activity.Ĭontrary to many of the other forum posts, importing the namespace is not actually required. Go to Design → New → Sequence to create a new sequence. Step-by-step Step 1: Create a new workflow. I’ll show step-by-step what you need to do and we will also discover a weird UiPath bug along the way! I have tested these steps with UiPath Studio v2018.3.1. Some people have been able to get it to work, but others have not been able to get it to work even when following their suggestions. People were looking for ways to use the Invoke Code activity along with the or assemblies. There are many questions on the forums on how to use the Microsoft Office COM interop with UiPath. This tutorial is a step-by-step guide on how to use MS Office COM interop with UiPath. HOWTO: Use MS Office COM interop with UiPath