import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
for wb in excel.Workbooks:
print(wb.Name)
When I run this script using Sublime Text:
A list of the names of open workbooks is printed.
When I run this script using PyCharm:
I get a blank list.
Both are on the same PC and are using the same version of Python (3.5 32-bit).
Not sure if this piece of info makes a difference, but I never ran the PyCharm installer when I first downloaded PyCharm. I downloaded the zip file and just run the PyCharm.exe from the unzipped folder every time. Could this be the reason why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…