Calling Access module functions from python

Chris Smith smitty_one_each at bigfoot.com
Fri Sep 23 12:29:06 EDT 2005


>>>>> "kayakerjess" == kayakerjess  <kayakerjess at hotmail.com> 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



More information about the Python-list mailing list