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.
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)…
… 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.