py2exe + win32com + DAO

Trevor trevor.lango at gmail.com
Wed May 13 07:06:42 CEST 2009


I do not believe your assertion applies to the following line of code:

daoEngine = win32com.client.Dispatch(r'DAO.DBEngine.36')

The preceding code snippet instantiates a COM object and is
prerequisite to creating a reference to a specific database:

daoDB = daoEngine.OpenDatabase(dbname)

As the compiled Python module executes successfully when invoked from
a command-line but not when invoked using the win32 CreateProcess
function, I suspect that one or more of the arguments to CreateProcess
is preventing successful execution.  I will investigate this further
(possibly on a win32 forum); however, is it possible to obtain more
verbose error output from Python modules?  The error message in the
original post was generated from:

print sys.exc_info()[0]

On May 12, 5:31 pm, David Lyon <david.l... at preisshare.net> wrote:
> Maybe VB is opening the table in Exclusive mode... then when you
> are opening it as a subprocess, it's already locked.
>
> It's possible the win32com module is not giving you a very
> descriptive error message.
>
> Try running your process while vb is running at the same time
> with the database open and if you get the same error then it
> might confirm my assertion.
>
> Otherwise it is likely that it is something else.
>
> On Tue, 12 May 2009 17:20:15 -0700 (PDT), Trevor <trevor.la... at gmail.com>
> wrote:
>
> > I have a Python code module that adds records to a MS Access
> > database.  The following line of code executes successfully when the
> > code module is run as a Python script:
>
> > daoEngine = win32com.client.Dispatch(r'DAO.DBEngine.36')
>
> > It also runs successfully when the Python script is compiled and run
> > as an executable using the Py2exe utility.  However, when the compiled
> > executable is called from VBA using the win32 CreateProcess function,
> > the preceding code produces this output:
>
> > !!python/name:pywintypes.com_error ''
>
> > What is causing this error?
>
>




More information about the Python-list mailing list