Python script running before passthrough is executed

Hi All

I have a python script which executes a macro from excel

import clr
import time
clr.AddReferenceByName(‘Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’)
from Microsoft.Office.Interop import Excel
from System.Runtime.InteropServices import Marshal
#time.sleep(3)

dirfichier = r"C:\Users\User\Desktop\ESTIMATING SHEETS\test\test steel\Structural Steel Estimate 2023.xlsm"
ex = Excel.ApplicationClass()
ex.Visible = True
ex.DisplayAlerts = False

wb = ex.Workbooks.Open(dirfichier)
ws = wb.Worksheets[1]

some code

time.sleep(3)

run macro named ‘Dynamo’ in excel

ex.Application.Run(“save1”)
wb.SaveAs(dirfichier)

if wb is not None:
Marshal.ReleaseComObject(wb)
if ex is not None:
Marshal.ReleaseComObject(ex)
wb = None
ex = None

OUT = [0]

Now my problem is it executes BEFORE the second write to excel is created. How do I get it to execute last?

Use the WaitFor node to hold it up until you have the right input.

That’s because your PassThrough is waiting on the first Excel node, not the python node. The passThrough input is what gets passed on and the waitFor input is what’s waiting to be execute before moving on. You don’t need a PassThrough or Wait node if the node you’re waiting on is also being passed on to the node you want to wait. A node has to have an input to execute (that’s how Wait nodes work) so you can typically rely on a node not executing until the node connecting into it has finished.

Also, as an FYI, please paste code as preformatted text from the source. Your second post is still unformatted since (I’m assuming) you copied it from the original paste, which is unformatted.