0

Just getting my feet wet with Python, and trying to automate some of my Access macros via accessing & running it with Python. I came across this which mostly solves this:

How to run a MS Access macro from python

import win32api,time
from win32com.client import Dispatch

strDbName = 'Exit.mdb'
objAccess = Dispatch("Access.Application")
objAccess.Visible = False
objAccess.OpenCurrentDatabase(strDbName)
objDB = objAccess.CurrentDb()
objAccess.run('test')
objAccess.Application.Quit()

I got this to work, but however, if the Macro being run has the action SetWarning to on, then Access "hangs", and stays open after running the Macro. (It seems to stay in locked mode - I have to go to taskManager to kill the session).

How would I get around this using the code? SetWarning action was on there to stop the user from having to not need the user confirm certain action queries (such as update tables). While this doesn't seem to happen anyway if I run the macro through python through above code snippet, I'd like to know reason and for above behavior - and it also prevents me from having to remove all the setWarning actions from all my current Access macros.

I've tried closeCurrentDb before calling the Application.Quit, but this doesn't seem to changing anything.

Senappa
  • 1
  • 1

0 Answers0