Join Club ShowMeDo to Learn Python!

This series is a part of Club ShowMeDo. Click to learn why you should join our club with a simple monthly subscription.

  • We teach Python and all the cool modules
  • Topics include beginner Python, GUIs, Web and Desktop Apps
  • Long, specially crafted video tutorials just for you
  • Club video tutorials extend our normal Free content
  • Save your time - we've done the research for you
  • Keep your skills up-to-date
  • Learn at your own pace, everything you need is shown to you
  • Over 12 hours of archived material are waiting for you in the club

Name: [002] Ian Ozsvald
Member: 105 months
Authored: 181 videos
Description: I am the co-founder of ShowMeDo (see http://showmedo.com/about), author of `The Screencasting Handbook <http://thescreencastinghandbook.com>`_ and the founder of the professional screencast production company `ProCasts <http://procasts.co.uk>`_: .. image:: http://procasts.co.uk/media/procasts_sma ...

Tip - Cleanly Quit Excel and del the local reference [ID:620] (3/6)

in series: COM and Python with pyWin32

(Showmedo is undergoing major changes. To report any problems viewing the videos please email us and include browser and OS specifics. Cheers - Kyran.)

When working with pyWin32 you'll probably run into this problem - you've worked with Excel and then closed it, you try to open it again and you get a half-broken screen. What's going on?!

The problem is that pyWin32 hasn't let go of its reference - if you look in the task-manager you'll see 'EXCEL.EXE' is still running. Here I show you how to cleanly shut-down Excel when you're done with it using this code:

In [55]: xlApp = Dispatch("Excel.Application")

In [56]: xlApp.Visible=1

In [57]: xlApp = Dispatch("Excel.Application")

In [58]: xlApp.Visible=1

In [59]: xlApp.Quit()

In [60]: del xlApp

Got any questions?

Get answers in the ShowMeDo Learners Google Group.

Video statistics:

  • Video's rank shown in the most popular listing
  • Video plays: 108 (since July 30th)
  • Plays in last week: 0
  • Published: 77 months ago

Thank-yous, questions and comments

If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?

You may also want to see our ShowMeDo Google Group to speak to our active users and authors.

Your email address will not be published.

Show some quick comments >>








All comments excluding tick-boxed quick-comments

Yeah i should have started with this one. had closed excel and python. then noticed i still had an instance of excel in the task manager.


Anon - you'll probably want to ask here:

http://mail.python.org/pipermail/python-win32/

and get yourself a copy of Python Programming on Win32 (O'Reilly).

Cheers,

Ian.


6. anonymous Wed, 06 Aug 2008 11:40

hi

2 questions

1.trying to access the path of a xl which is allready open

2.trying to get the sheet name of the allready open

thanks in advance

Sri


Review of Tip - Cleanly Quit Excel and del the local reference

excellent information... this is very useful outside of just excel...


Hi Tal. I think you're right, I didn't observe anything odd in my testing but since the garbage-collector doesn't have to delete the instance straight away, something odd could happen there.

From my testing these seemed to be the right way to do things, perhaps if this fails for someone they could post a follow-up comment?

Ian.


Are you sure that "del xlApp" always works? Doing "del" on a variable doesn't necessarily call the underlying instance's __del__ method, even if its refcount drops to zero, due to the mechanics of CPython's garbage collection. It is possible that the behavior is consistent in this case, I'm just wondering if you checked this out.

Anyways, thanks for this, it is very useful! I once spent hours figuring this out for myself...


this is good when more are coming.. im waiting


Video published, thanks for contributing to ShowMeDo


Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Ian

Content

Feedback

Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.

feedback@showmedo.com