From 57104ba3838bc7e8a9fdffb7c0cf48e66c9cee2b Mon Sep 17 00:00:00 2001 From: Bethany Nicholson Date: Mon, 17 Jun 2019 15:26:34 -0600 Subject: [PATCH 1/2] Use DispatchEx to launch Excel to not interfere with any open Excel windows --- pyutilib/excel/spreadsheet_win32com.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyutilib/excel/spreadsheet_win32com.py b/pyutilib/excel/spreadsheet_win32com.py index 78789e76..7afadd9f 100644 --- a/pyutilib/excel/spreadsheet_win32com.py +++ b/pyutilib/excel/spreadsheet_win32com.py @@ -20,7 +20,7 @@ # set a flag to tell the ExcelSpreadsheet class that it should # raise an exception in its constructor. # -from win32com.client.dynamic import Dispatch +from win32com.client import DispatchEx as Dispatch from pythoncom import CoInitialize, CoUninitialize, com_error from pyutilib.excel.base import ExcelSpreadsheet_base From fc6fef58b0b5c93f6bd43e7a31ccf45ce1c8abd3 Mon Sep 17 00:00:00 2001 From: Bethany Nicholson Date: Mon, 17 Jun 2019 16:41:15 -0600 Subject: [PATCH 2/2] Adding a comment on the use of DispatchEx for future reference --- pyutilib/excel/spreadsheet_win32com.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyutilib/excel/spreadsheet_win32com.py b/pyutilib/excel/spreadsheet_win32com.py index 7afadd9f..986bdbac 100644 --- a/pyutilib/excel/spreadsheet_win32com.py +++ b/pyutilib/excel/spreadsheet_win32com.py @@ -19,7 +19,11 @@ # Attempt to import win32com stuff. If this fails, then # set a flag to tell the ExcelSpreadsheet class that it should # raise an exception in its constructor. -# + +# BLN: Use DispatchEx instead of Dispatch to make sure we launch +# BLN: a new instance of Excel, otherwise we unintentionally +# BLN: close any open Excel Windows when importing Pyomo +# BLN: See https://github.com/Pyomo/pyomo/issues/355 from win32com.client import DispatchEx as Dispatch from pythoncom import CoInitialize, CoUninitialize, com_error