Read Excel file node Opens Excel file

i have put together a bit of python code which closes the active workbook, you should be able to copy and paste the below code in. It uses an if statement as a trigger. Its a bit messy as you need to use this everytime a spreadsheet is opened. Ideally, would want this to run right at the end and close specific excel files. Hope it helps.
from System.IO import Directory
import re
import time
import sys
sys.path.append(‘C:\Program Files (x86)\IronPython 2.7\Lib’)
import subprocess
import os
import errno
import csv
import clr
clr.AddReferenceByName(‘Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’)
from Microsoft.Office.Interop import Excel
from Microsoft.Office.Interop.Excel import ApplicationClass
from System.Runtime.InteropServices import Marshal

if “Completed” in IN[0]:

ex = Excel.ApplicationClass()
xlApp = Marshal.GetActiveObject("Excel.Application")	
xlApp.Visible = True
xlApp.DisplayAlerts = False
xlApp.Workbooks.Close()
xlApp.Quit()

OUT = “Success”

3 Likes