This question is related to my previous question found here: Python code for running ms-Access Module Subroutine
To explain my problem I will give a breif description of what I am trying to do:
I have made a GUI using python and tkinter that lets the user choose different search criterias, and then prints these criterias to a .txt file. The python code then launches an instance of Access using the following code:
objAccess = win32com.client.Dispatch("Access.application")
objAccess.Visible = True
objAccess.OpenCurrentDatabase(filepath)
objAccess.DoCmd.RunMacro("Macro1")
The macro is a simple "RunCode" command with Function Name My_Function(). My_Function() reads the .txt file, performs queries to the database, generates reports and saves the reports in pdf-format in the current folder and then shuts down Access using:
DoCmd.Quit
I am pretty sure this all worked as intended, until I moved the files (the python script and the Access database) to a new folder. After the move, everything runs just as before, i.e. Access opens a window, generates the reports according to the user input and then shuts down. BUT unlike before I moved the files, the python console (I'm using Spyder with Python 2.7) reports the following exception:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1532, in __call__
return self.func(*args)
File "C:/Users/nx71/ProsjektreferanserPython/Test_final/GUI_02_norsk.py",
line 269, in buttonclick2
objAccess.DoCmd.RunMacro("Macro1")
File "<COMObject <unknown>>", line 3, in RunMacro
com_error: (-2147352567, 'Exception occurred.', (0, None, u'The | action was canceled.
', None, -1, -2146825787), None)
Additionally, after running the script, I am unable to open any Access database by doubleclicking the icon, unless I enter the Task Manager, select the single Access background process and "End Task".
So in short: The script+macro+function does what I want it to do, but after I moved the files, the console reports an exception and an Access bacground process lingers and prevent me from opening a new instance of Access.
Ps: I'm using Windows 10 and MS Office 2013.
Any help will be greatly appreciated!