I'm trying to execute a function in vba inside a ms access db with python.
I tried this:
strDbName = "PathToMyDb"
ac = win32com.client.Dispatch ( "Access.Application" )
ac.OpenCurrentDatabase ( strDbName,False)
ac.Run("Performance_Attr_ModuloXX")
ac.Application.CloseCurrentDatabase ( )
ac.Application.Quit ( )
But I keep getting this error:
Traceback (most recent call last):
File "C:\Users\PIN\PycharmProjects\test_db\main.py", line 32, in <module>
ac.Run("Performance_Attr_ModuloXX")
File "<COMObject Access.Application>", line 14, in Run
File "C:\Users\PIN\PycharmProjects\test_db\venv\lib\site-packages\win32com\client\dynamic.py", line 369, in _ApplyTypes_
*(dispid, LCID, wFlags, retType, argTypes) + args
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352562), None)
I already tried to check the function in vba and it works.