I am trying to pass workbook instance from one sequence to another. it is working fine is its normal sheet (Read and write operation). Moreover if the excel has add-in control or ActiveX control then it throws and error. Below is there error:
System.InvalidCastException: Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.Office.Interop.Excel._Workbook’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{000208DA-0000-0000-C000-000000000046}’ failed due to the following error: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA).\r\n at UiPath.Excel.Activities.InvokeVBA.EndExecute(AsyncCodeActivityContext context
Try going to options in excel and enable macros and disable external links or activex and all from the trust centre may be they are causing issue. And if you are trying to use macro then try with setting excel to visible .
The option of Macro is already enable however disable Activex control is not an option as we need to perform an operation on those control. and we have use Invoke Vb code for the same.
and also same code is working fine if the excel object is created in same sequence. but when i pass it to different sequence then the problem arise.
I see one more thing here in your inner workflow pass the wb variable both in existing and the output fields .that might shed some light.check my previous comment as well
We have to do it in this way only the reason is at some place i need to perform an operation in Activex control . So we have used Invoke VB code , which will only work when it is inside Excel scope. Now the requirement is, there are 100 of controls and we need to perform and operations on those controls. So there is inner sequence and there is one main sequence that’s why i am doing it like this
I agree with your point, but what i see is the first thing that you do in the excel scope as per screenshot is invoke what i am saying is move that invoke outside as inside invoke you would already have had an excel acope qhich will take care of whatever steps that you do there and pass it out and use excel acope again the same way
What is the reasoning for passing the workbook as an argument to another workflow? Would it be possible to only pass the file path and open it within an Excel Application Scope in a different workflow?
If you observe the structure , there are 100 of Activex control with we need to perform an action based on certain condition. However we try it for the first time and if its fail we retry it in catch block. We instead of writing a separate block in each catch we have written common sequence and pass the Excel object and control name. As it execute the different sequence in catch block and then we need to resume on main flow for rest of the control.
Sending an Excel path is not an option because we don’t know when the failure occurred and it will go to catch block. As we need to work on different control on same excel and same sheet.