Robot Structural Analysis 2025-Close Excel Dynamo

Robot Structural Analysis 2025-Close Excel Dynamo

stefanyC6JZ7
Enthusiast Enthusiast
258 Views
2 Replies
Message 1 of 3

Robot Structural Analysis 2025-Close Excel Dynamo

stefanyC6JZ7
Enthusiast
Enthusiast

Hello everyone, 
I am trying to use RSA2025 to run dynamo scripts. I am trying to close Excel with the script but I get the following error: 

stefanyC6JZ7_0-1722870458060.png

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]))

 Could you please help me solving this issue? 

Best regards,
Stefany 

0 Likes
259 Views
2 Replies
Replies (2)
Message 2 of 3

1234eddie
Advocate
Advocate

Hi All,

 

just to add a little bit extra information. 

Here is the full error message

Message

FileNotFoundException : Unable to find assembly ‘Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’. at Python.Runtime.CLRModule.AddReference(String name)

at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)

at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr) [’ File "

 

Version Dynamo RSA 2022 runs fine.

1234eddie_0-1722935596107.png

 

Version Dynamo RSA 2025 

1234eddie_1-1722935625716.png

 

 

I hope @okapawal @Rafal.Gaweda or maybe others can have a quick look at this?

 

Many thanks in advance

 

Gr Edward

 

0 Likes
Message 3 of 3

okapawal
Autodesk
Autodesk

@1234eddie 
Can you check or post it n the Dynamo Forum ?  Dynamo (dynamobim.com)

It is rather Dynamo core issue.

 



Waldemar Okapa

Sr Product Owner
0 Likes