[英]python win32com Dispatch fails with 'CrystalRuntime.Application' (64bit issue)
The essential details here are as follows: 这里的基本细节如下:
My problem is the following code fails when Dispatch('CrystalRuntime.Application') is called, this worked fine on same 32bit OS configuration of the above. 我的问题是,调用Dispatch('CrystalRuntime.Application')时,以下代码失败,这在上述相同的32位OS配置上正常运行。
The error being: 错误是:
(-2147221164, 'Class not registered', None, None)
I've spent hours going through various reason why this is failing and I've got nowhere.. 我已经花了几个小时来研究失败的各种原因,但我却一无所获。
I've even run makepy.py on the 'Crystal Reports ActiveX Designer Run Time Library' which contains the com interface I'm trying to create, but even this fails to deliver a result. 我什至在“ Crystal Reports ActiveX Designer运行时库”上运行makepy.py,该库包含我要创建的com接口,但即使这样也无法提供结果。
I know crystal is installed correctly as it works perfectly well and I can see the com classes registered correctly. 我知道crystal安装正确,因为它可以很好地工作,并且我可以看到com类已正确注册。
I completely stuck and need help, as always i hope stack can come to my rescue again... 我完全陷入困境,需要帮助,一如既往,我希望堆栈可以再次帮助我...
Any thoughts, please bear in mind i'm not a python programmer of any magnitude... 任何想法,请记住我不是任何规模的python程序员...
import os
import sys
import re
import time
from win32com.client import Dispatch
import pythoncom
def main():
try:
app = Dispatch('CrystalRuntime.Application')
print app
except pythoncom.com_error, e:
print "(crystal reports not installed?): '%s'" % e
return 0
print 'Success!!!'
if __name__ == '__main__':
main()
When I use py26 with Excel, I've found that this syntax works better. 当我将py26与Excel结合使用时,我发现此语法效果更好。
Excel_App = win32com.client.gencache.EnsureDispatch('Excel.Application')
Maybe that can be altered to fit crystal reports.. 也许可以更改以适合水晶报表。
App= win32com.client.gencache.EnsureDispatch('CrystalRuntime.Application')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.