Hi guys,
Take the scenario whereby I have two spreadsheets open, one on which I run my xlwings function (call it fileA)and the other on which I'm currently doing something else (call it fileB)
when I have something running on fileB be it a formula highlighted or a form window open, then I run my xlwings fct on file A, that usually generates an Attribute error :
AttributeError: .Application
As a potential fix, I realised that
changing the exception handling in get_xl_apps() in file _xlwindows.py
from :
def get_xl_apps():
xl_apps = []
hwnds = get_excel_hwnds()
for hwnd in hwnds:
try:
xl_app = get_xl_app_from_hwnd(hwnd)
xl_apps.append(xl_app)
except WindowsError:
# This happens if the bare Excel Application is open without Workbook
# i.e. there is no 'EXCEL7' child hwnd that would be necessary to make a connection
pass
return xl_apps
to
def get_xl_apps():
xl_apps = []
hwnds = get_excel_hwnds()
for hwnd in hwnds:
try:
xl_app = get_xl_app_from_hwnd(hwnd)
xl_apps.append(xl_app)
except (WindowsError,AttributeError):
# This happens if the bare Excel Application is open without Workbook
# i.e. there is no 'EXCEL7' child hwnd that would be necessary to make a connection
pass
return xl_apps
tends to solve the problem
Hi guys,
Take the scenario whereby I have two spreadsheets open, one on which I run my xlwings function (call it fileA)and the other on which I'm currently doing something else (call it fileB)
when I have something running on fileB be it a formula highlighted or a form window open, then I run my xlwings fct on file A, that usually generates an Attribute error :
AttributeError: .Application
As a potential fix, I realised that
changing the exception handling in get_xl_apps() in file _xlwindows.py
from :
to
tends to solve the problem