Odd Excel Interop Behavior

In my sequence I created four global variables:

excel - microsoft.office.interop.excel
workbook - microsoft.office.interop.excel.workbook
sheets - microsoft.office.interop.excel.sheets
worksheet - microsoft.office.interop.excel.worksheet

My goal is to initiate the variables and pass the variables to different Invoke Code activities via the activity’s IN/OUT arguments. I am able to pass the excel and workbook variables, but get the following error for the sheets and worksheet variables:

“A value of type ‘System.__ComObject’ cannot be set to the location with name sheets because it is a location of type ‘Microsoft.Office.Interop.Excel.Sheets’.”

Hi @ToddPull Did you solve this ??
I am facing same issue . Please put solution here in case you got one

Try opening the XAML file in a text editor to check if there is an AssemblyReference for Microsoft.Office.Interop.Excel. Although you import the reference sometimes it isn’t written to the XAML file.

I’ve also have found it is easier to write and save the VBA code to a script file and then use the Invoke VBA activity instead of using Interop.