Author Topic: Miscellaneous question  (Read 502 times)

aavanian

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Miscellaneous question
« on: September 30, 2015, 07:12:23 AM »
Hello,

here's a few misc. questions:
  • I use PyCharm as IDE which does real-time code inspection and referencing. It gets stuck on the pyxll import statements considering the package not installed. Should I point it to pyxll.py?
  • Several of my functions make database queries. I'm wondering what is the persistence of variables between function calls, excel instances, etc... If I declare a global variable in an imported module, is it available and persisted across all function calls of all excel instances or all function calls of a single workbook? Is there a way to call a function on excel exit (to clean-up db connections)?
  • I get this warning in the PyXll log: "WARNING : InitCommonControlsEx failed with code 0" but no ill side-effect. Is there something I should do about it?

Thanks in advance,
Alexandre

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 574
  • Karma: +13/-1
    • View Profile
Re: Miscellaneous question
« Reply #1 on: September 30, 2015, 07:51:04 AM »
Hi Alexandre,

yes, that's exactly what the pyxll.py stubs file is for. You can also use it for unit tests or anywhere else you need to run your code outside of Excel.

It's a single Python interpreter, so all globals are persisted across all function calls in the same Excel instance (regardless of how many workbooks you have open in the same Excel instance). If you run multiple Excel processes they are independent.

No that's nothing to worry about. It just means that windows call has already been called elsewhere (i.e. by Excel when it starts up). I should remove that warning...

Best regards,
Tony

aavanian

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Miscellaneous question
« Reply #2 on: September 30, 2015, 10:58:14 AM »
Understood, thanks