Connect to VBA Objects?

Discussion in 'Python' started by Dave Brueck, Sep 22, 2003.

  1. Dave Brueck

    Dave Brueck Guest

    On Monday 22 September 2003 07:38 pm, Kenneth Hutson wrote:
    > Hi,
    > I wonder if Python can connect to the object models exposed by Excel or
    > Word.
    > Thanks in advance,
    > Ken Hutson
    > San Antonio, Texas


    Yep, assuming you have the win32all extensions installed:

    from win32com.client import Dispatch
    d = Dispatch('Word.Application')
    d.Visible = 1
    ....

    -Dave
     
    Dave Brueck, Sep 22, 2003
    #1
    1. Advertising

  2. Hi,
    I wonder if Python can connect to the object models exposed by Excel or
    Word.
    Thanks in advance,
    Ken Hutson
    San Antonio, Texas
     
    Kenneth Hutson, Sep 23, 2003
    #2
    1. Advertising

  3. Dave Brueck

    Bob Gailer Guest

    At 07:38 PM 9/22/2003, Kenneth Hutson wrote:

    >Hi,
    >I wonder if Python can connect to the object models exposed by Excel or Word.


    Use Mark Hammond's win32all.
    http://starship.python.net/crew/mhammond/win32/Downloads.html

    import win32com.client
    app = win32com.client.Dispatch("word.application")
    app.visible = 1
    documents = self.app.Documents
    doc = documents.Add("c:\\foo.doc")

    etc.

    app = win32com.client.Dispatch("excel.application")
    app.visible = 1
    app.WorkBooks.Open("c:\\foo.xls")

    etc.

    Bob Gailer

    303 442 2625


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003
     
    Bob Gailer, Sep 23, 2003
    #3
  4. Dave Brueck

    Peter Hansen Guest

    Peter Hansen, Sep 23, 2003
    #4
  5. Many thanks to Bob Gailer, Dave Brueck and Peter Hansen.
    Kenneth Hutson
    San Antonio, Texas

    "Kenneth Hutson" <> wrote in message
    news:...
    > Hi,
    > I wonder if Python can connect to the object models exposed by Excel or
    > Word.
    > Thanks in advance,
    > Ken Hutson
    > San Antonio, Texas
    >
    >
     
    Kenneth Hutson, Sep 23, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Iulian Dan Repolschi

    pass VBA class module to c# objects

    Iulian Dan Repolschi, May 20, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,932
    Eric Marvets
    May 22, 2004
  2. Otis Mukinfus
    Replies:
    3
    Views:
    957
    Juan T. Llibre
    Jul 8, 2005
  3. Replies:
    3
    Views:
    40,648
    Roedy Green
    Nov 16, 2005
  4. Replies:
    2
    Views:
    325
  5. Mohsen Pahlevanzadeh

    Qt connect and first connect or unicode

    Mohsen Pahlevanzadeh, Sep 17, 2013, in forum: Python
    Replies:
    3
    Views:
    176
    Mohsen Pahlevanzadeh
    Sep 18, 2013
Loading...

Share This Page