Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 323441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:01:53+00:00 2026-05-12T09:01:53+00:00

I am trying to do a sample app in python which uses some COM

  • 0

I am trying to do a sample app in python which uses some COM objects. I’ve read the famous chapter 12 from Python Programing on Win32 but regarding this issue it only states:

All event handling is done using
normal IConnectionPoint interfaces,
and although beyond the scope of this
book, is fully supported by the
standard Python COM framework.

Can anybody shed some light on this? I’d need a simple starter sample. Something like adding code to this sample to catch the OnActivate event for the spreadsheet

import win32com.client
xl = win32com.client.Dispatch("Excel.Application")
...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:01:53+00:00Added an answer on May 12, 2026 at 9:01 am

    I haven’t automated Excel, but I’m using some code from Microsoft’s Speech API that may be similar enough to get you started:

    ListenerBase = win32com.client.getevents("SAPI.SpInProcRecoContext")
    class Listener(ListenerBase):
        def OnRecognition(self, _1, _2, _3, Result):
            """Callback whenever something is recognized."""
            # Work with Result
    
        def OnHypothesis(self, _1, _2, Result):
            """Callback whenever we have a potential match."""
            # Work with Result
    

    then later in a main loop:

        while not self.shutting_down.is_set():
            # Trigger the event handlers if we have anything.
            pythoncom.PumpWaitingMessages() 
            time.sleep(0.1) # Don't use up all our CPU checking constantly
    

    Edit for more detail on the main loop:

    When something happens, the callback doesn’t get called immediately; instead you have to call PumpWaitingMessages(), which checks if there are any events waiting and then calls the appropriate callback.

    If you want to do something else while this is happening, you’ll have to run the loop in a separate thread (see the threading module); otherwise it can just sit at the bottom of your script. In my example I was running it in a separate thread because I also had a GUI running; the shutting_down variable is a threading.Event you can use to tell the looping thread to stop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 202k
  • Answers 202k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, this is possible! The elements of your form will… May 12, 2026 at 8:21 pm
  • Editorial Team
    Editorial Team added an answer They address a limitation of PHP, which doesn't generate an… May 12, 2026 at 8:21 pm
  • Editorial Team
    Editorial Team added an answer The error relates to moving an object onto a part… May 12, 2026 at 8:21 pm

Related Questions

I have a modest-sized table, 277k records at the moment, which I am trying
I'm trying to test the functionality of a web app by scripting a login
This is a two part question. A dumb technical query and a broader query
I have a django application using mod_python, fairly typical configuration except that media files

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.