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?