Calling Access module functions from python

Discussion in 'Python' started by kayakerjess, Sep 21, 2005.

  1. kayakerjess

    kayakerjess Guest

    Hi,

    I have an Access Data Project (.adp) that I am trying to open and
    execute from Python. I am using the win32com.client, and I have
    successfully opened the application, but I'm getting an exception when
    I try to execute the function (actually a "Sub" that returns void, but
    that shouldn't matter). Here's what I have so far:


    conn=win32com.client.Dispatch('Access.Application')
    conn.OpenAccessProject("C:/path/to/file/filename.adp")
    conn.Visible = 1
    # works so far

    conn.Run("test_interface")

    # Exception is thrown here.
    # com_error: (-2147352567, 'Exception occurred.', (0, None, None, None,
    0, -2147352562), None)

    The 'test_interface' function takes no arguments, but I've tried the
    same thing with another function that does take arguments and gotten
    the same result.

    Any help would be appreciated.

    Thanks,
    kayakerjess
     
    kayakerjess, Sep 21, 2005
    #1
    1. Advertising

  2. kayakerjess

    Chris Smith Guest

    >>>>> "kayakerjess" == kayakerjess <> writes:

    kayakerjess> Hi, I have an Access Data Project (.adp) that I am
    kayakerjess> trying to open and execute from Python. I am using
    kayakerjess> the win32com.client, and I have successfully opened
    kayakerjess> the application, but I'm getting an exception when I
    kayakerjess> try to execute the function (actually a "Sub" that
    kayakerjess> returns void, but that shouldn't matter). Here's
    kayakerjess> what I have so far:


    kayakerjess> conn=win32com.client.Dispatch('Access.Application')
    kayakerjess> conn.OpenAccessProject("C:/path/to/file/filename.adp")
    kayakerjess> conn.Visible = 1 # works so far

    kayakerjess> conn.Run("test_interface")

    kayakerjess> # Exception is thrown here. # com_error:
    kayakerjess> (-2147352567, 'Exception occurred.', (0, None, None,
    kayakerjess> None, 0, -2147352562), None)

    kayakerjess> The 'test_interface' function takes no arguments, but
    kayakerjess> I've tried the same thing with another function that
    kayakerjess> does take arguments and gotten the same result.

    kayakerjess> Any help would be appreciated.

    kayakerjess> Thanks, kayakerjess

    Assuming you have a copy of Access, no?
    I would recommend lighting off Access, and exploring the Modules
    collection. Possibly start a new file, and see if you can prototype
    your python code in Visceral Baysuck for crApplications, (which is
    actually a better tool than my sophomoric comment implies).
    The modules collection may let you invoke a Sub in one of them.
    Google might also yield something.
    HTH,
    Chris
     
    Chris Smith, Sep 23, 2005
    #2
    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. Daniel Vallstrom
    Replies:
    2
    Views:
    2,039
    Kevin Bracey
    Nov 21, 2003
  2. Mark Carter
    Replies:
    1
    Views:
    510
    Koczian
    Jul 11, 2003
  3. kayakerjess
    Replies:
    0
    Views:
    334
    kayakerjess
    Sep 21, 2005
  4. S?ren Gammelmark
    Replies:
    1
    Views:
    1,984
    Eric Sosman
    Jan 7, 2005
  5. Ross A. Finlayson
    Replies:
    19
    Views:
    650
    Keith Thompson
    Mar 10, 2005
Loading...

Share This Page