0
votes

The essential details here are as follows:

  • Windows Server 2008 64bit
  • Python26 64bit
  • Visual Studio 2008(Team) which installs Crystal Reports (both 32bit and 64bit runtimes)

My problem is the following code fails when Dispatch('CrystalRuntime.Application') is called, this worked fine on same 32bit OS configuration of the above.

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.

I know crystal is installed correctly as it works perfectly well and I can see the com classes registered correctly.

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...

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()
1
OK, got a little further analysing this. If I do more or less the same in a vb script file, and call the script file with 'cscript.exe', initially I get the same result. However, if I call the vb script file using the 'C:\Windows\SysWOW64\cscript.exe' which I believe runs this script as a 32bit process, it works. So..... what do I need to do to get the python script to behave the same, as i dont want to re-write the whole script in vb, just for the sake of a few line which dont work. - DIGGIDY

1 Answers

0
votes

When I use py26 with Excel, I've found that this syntax works better.

Excel_App = win32com.client.gencache.EnsureDispatch('Excel.Application')

Maybe that can be altered to fit crystal reports..

App= win32com.client.gencache.EnsureDispatch('CrystalRuntime.Application')