well i've searched for two days on how to fix this problem and found nothing. what i'm trying to do is call python functions and stuff from within vb6. Here's the steps I took
1) I have vb6 and sp6 installed
2) I install activepython 2.7 because it includes win COM stuff
3)I create the folder C:\PythonVB
4)I created the python script called 'PythonVB3.py' with the following code
5) I double clicked the script above which registered itselfCode:class PythonVB3: #Public Methods available to VB _public_methods_ = ['SayHello'] #Class Name Created in VB. #Example Set objPython = CreateObject("PythonVB3.Demo") _reg_progid_ = "PythonVB3.Demo" #Never Copy this GUID! Use pythoncom module to create a new one #Example: import pythoncom # print pythoncom.CreateGuid() _reg_clsid_ = "{EE2946AE-79DD-49D1-992D-F4FF6431A2F0}" def SayHello(self): return "Hello from Python!!" if __name__ =='__main__': print "Registering COM Server..." import win32com.server.register win32com.server.register.UseCommandLine(PythonVB3)
This tool 'RegDLLView' from nirsoft shows it registered correctly
6)I created a new standard exe project in vb6 with the following code
7)when I compiled and try to execute(in C:\PythonVB) I get errorCode:Private Sub Form_Load() Dim objPythonVB As Object Dim retval As Long Set objPythonVB = CreateObject("PythonVB3.Demo") retval = objPythonVB.SayHello() MsgBox retval End Sub
I tried manually adding a reference to pythoncom27.dll too and it wouldn't let me :\ any help or advice would be much appreciated. I also uninstalled/reinstalled everything and only have 1 version of python installed.






Reply With Quote