How can I convert an object of Type 'Object' to an array of String in UiPath

I am getting error while trying to convert an object of type Object to String Array using DirectCast Method. Please help

what is your object ?

thanks I got the Answer.

the Object was of type Object Class.

1 Like

Hi, I could use some help with a similar issue. The output from an excel macro is an object type in UiPath. The excel macro returns a Date() array. I need to work with this MacroOutput object. I have tried Directcast and Convert.changetype but neither will compile in UiPath. I get the Option Strict On error trying to make an implicit conversion. I think I need to find a fix to the error in the vb code rather than try to turn off Option Strict.

Here is what I’ve tried:

MacroOutput (astype Object)
NewDates (astype DateTime())

NewDates = convert.ChangeType(MacroOutput,NewDates.GetType)

Another option: I can see the MacroOutput array in the locals window during execution and it has the proper dates I need to work with, so I know it is valid. How do I assign a variable to the MacroOutput object in UiPath? The assign container will not accept the simple NewDate(0) = MacroOutput(0) due to the Strict On option

Thanks for your thoughts.

In my search, I found the answer…I overlooked the VB CType function and that did the trick. For others to learn if reading this post…in an assign container:

NewDates = ctype(MacroOutput, Date())

1 Like

Both CType and DirectCast will work.

Hi, thanks, that makes perfect sense that both will work. I think when I first tried DirectCast, my syntax was wrong.

1 Like

I had the same situation and to fix it, instead of outputting an array, I concatenate my strings together with “,” as separator. Then I get the macro output as string in uipath and use the split method to transfer my strings to an array variable (String).

Hope that helps.

Hi @vikasrawat911 - could you expand on this?