Tip: Another Way to use COM Libraries with UiPath

The Component Object Model (COM) on Windows platform is a very important technology to provide libraries that can be used by many programming languages or applications. E.g. UiPath offers therefor an Invoke COM Method activity. The programming languages offers in a normal case a set of methods to handle COM libraries, e.g. like this:

  • CreateObject = Creates an object of a registered class
  • GetObject = Gets the object of an instantiated class
  • GetProperty = Gets a property of an object
  • SetProperty = Sets a property of an object
  • CallMethod = Executes a method of an object
  • FreeObject = Destroys an object

To offer a comparable way for UiPath I developed a Custom Activity called InteractCOM. It offers exact these methods.

Therewith you can handle COM libraries like in any programming language. Here an example how to execute a VBScript code via MSScriptControl.ScriptControl COM library. Not a very good example, but it shows the possibilities.

We start with a tiny VBScript function foo, which we put as string in the variable code.

003

In the first step of COM methods we create the object MSScriptControl.ScriptControl. We store the reference to the object in the variable VBScript.

Now we set two properties, AllowUI and Language. The parameters are an array of objects. If a method or property has no parameters, an empty array must be specified here.

Then we add the code with the method AddCode.

Now we call the method Eval to execute our code.

Last but not least we destroy the created object.

When we run the workflow we get the message box and if we press Yes (Ja)…

010

… it delivers the correct value in the variable Res.

In my opinion is this standard way, which bases on the common procedures of programming languages, an acceptable approach. In this kind of designing environment it is more laborious, but it is clean and easy to understand, if it is a separate sequence.

You can find the Custom Activity InteractCOM at my homepage.

Furthermore offers this library the possiblity to detect existing objecte via GetObject. As I said, this corresponds to programming languages.

4 Likes

Hi @StefanSchnell,

Can you share the sample workflow as well for this.

Best!!
Anmol

1 Like

@anmolk171

Hello Anmol,
sure, no problem.

InteractCOM.WorkFlow.zip (1.6 KB)

Best regards
Stefan

1 Like