Hello, The following code works when typed into IronPython console. But when I save the code into a file named excel.py and run ipy.exe excel.py, the event handling does not seem to work. Nothing happens when a new workbook is created.
Any suggestion? Thanks a lot. import clr clr.AddReference("Microsoft.Office.Interop.Excel") import Microsoft.Office.Interop.Excel as Excel clr.AddReference('System.Windows.Forms') import System.Windows.Forms.MessageBox as MessageBox def getActiveObject(appId): from System.Runtime.InteropServices import Marshal return Marshal.GetActiveObject(appId) def getActiveExcelApplication(): return getActiveObject("Excel.Application") def onNewWorkbook(workbook): print "Creating a new workbook..." MessageBox.Show("Creating a new workbook...") xlApp = getActiveExcelApplication() MessageBox.Show(xlApp.ActiveWorkbook.Name) #This line works. Excel.AppEvents_Event.add_NewWorkbook(xlApp, onNewWorkbook) #This line does not work. -- Kelie _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com