In Robot structural analysis 2022 with Dynamo we are using a python script that closes the excel file that’s beiing used before the new one gets opened.
At the moment we are trying to upgrade to RSA 2025 and want to use the same script. but we get the following error:
Please find the code from the script below :
import sys
import clr
import System
clr.AddReference('Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')
from Microsoft.Office.Interop import Excel
from System.Runtime.InteropServices import Marshal
def excel_close(lst_namefile):
xlApp = Excel.Application(Marshal.GetActiveObject("Excel.Application"))
print(xlApp)
allWorkbooks = Excel.Workbooks(xlApp.get_Workbooks())
print([x for x in allWorkbooks])
lst_WkbsName = [Excel.Workbook(x).get_Name() for x in allWorkbooks]
for namefile in lst_namefile:
if namefile in lst_WkbsName:
Tesluiten = Excel.Workbook(allWorkbooks.get_Item(namefile))
Tesluiten.Close()
xlApp.Quit()
toList = lambda x : x if isinstance(x, list) else [x]
OUT = excel_close(toList(IN[0]))
Ok, this indicates the issue is likely with the .NET 8 update.
Can you copy the full error message from the Graph node manager UI? (Open it from the extensions menu, find the node in the list and copying the message should be straightforward)
Bit outside the areas I am working in this week (ok light years away) and I’m on vacation the next two so I may not be of much help, but let me see what I can find.
We have a dynamo file, in that file we fill the names of all the excel files that needs to be calculated [it needs to be one file at the time], in the end of the ‘.DYF node’ the file should close, before the next file get opened.
the switch to Net 8 (.Net Core) means that we can no longer use directly assemblies in the windows GAC (like Excel Interrop)
so clr.AddReference('Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c') failed
Marshal.GetActiveObject is not available in .Net 8
Maybe you can use OpenXml to read / write the Excel file ?