1

I have the following Python 2.7 code that works perfectly on a Windows 7 machine:

from comtypes.client import CreateObject
app = CreateObject('Access.Application')
from comtypes.gen import Access
DBEngine = app.DBEngine

On two others (Windows 7 and Windows 10) with MS Access 365 installed (latest version), I get the following error:

_ctypes.COMError: (-2147312566, 'Erreur lors du chargement de la biblioth\xe8que/DLL du type.', (None, None, None, 0, None))

(Meaning "Error loading DLL library)

I assume it's a DLL issue. Reinstalling Office didn't solve it. Has anyone already met that issue? Otherwise, what would be the general method to find the problem/fix it?

fralau
  • 3,279
  • 3
  • 28
  • 41
  • [DBEngine](https://msdn.microsoft.com/en-us/library/office/ff821724.aspx) requires the Microsoft Access database engine which some users may have to separately download its [set of components](https://www.microsoft.com/en-us/download/details.aspx?id=54920) – Parfait Mar 29 '17 at 19:56

2 Answers2

1

I found the answer to that question: the "click-to-run" version of Office 365 runs in a virtual environment and the Python libraries may not find it.

The answer to that issue is to uninstall Office and reinstall it as a normal download. After we did that, the program (which had already been tested successfully on another machine) started working fine.

fralau
  • 3,279
  • 3
  • 28
  • 41
0

Why not using win32com.client for that? comtypes is not so stable and is useful for custom COM interfaces (where other approach is impossible). All MS Office products have nice and standard IDispatch COM interface that are reachable by win32com.client. Standard PyWin32 docs describe "Excel.Application" example, but it can be easily applied for MS Access as well.

Fortunately there are several examples on StackOverflow:

Python code for running ms-Access Module Subroutine

Python Create Access database using win32com

Community
  • 1
  • 1
Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78