On 11/12/2009 4:41 PM Yashwin Kanchan said...
Hi Guys

I am trying to create a simple test COM server , but am have trouble assigning any property value to it through excel VBA.

Please point out where i am going wrong.


#COM server
class test(object):

    _reg_clsid_ = "{B5901450-F9A1-4F76-8FCF-2BFFA96ED210}"
    _reg_progid_ = "Python.Test"
    _public_methods_ = ["arg"]

My bet is that the problem is here.  Do you need to expose t as well?

I wrote one of these six or seven years ago -- here're the critical bits (where EMSpecs is a class defined in the same module):

class fenxUtilities:
    _public_methods_ = [ 'FirstPartInsp' ]
    _reg_progid_ = "fenxDCom.Util"
    _reg_clsid_ = "{3EAD7AB4-2978-4360-8F7D-33FB36E9E146}"
    def FirstPartInsp(self, nomDiam, numFlutes, nomOAL, nomLOC):
        return EMSpecs(nomDiam, numFlutes, nomOAL, nomLOC).retvals


if __name__=='__main__':
    print "Registering COM server..."
    import win32com.server.register
    win32com.server.register.UseCommandLine(fenxUtilities)

HTH,

Emile


    _public_attrs_ = ["t"]
def __init__(self):
        self._t=0
def arg(self,s,r):
        return (s,r)
def get_t(self):
        return self._t
def set_t(self,value):
        self._t = str(value)
t = property(get_t,set_t) if __name__=='__main__':
    import win32com.server.register
    win32com.server.register.UseCommandLine(test)
    print "done"

VBA Code:

Sub Button1_Click()
    Set test = CreateObject("Python.Test")
    test.arg 2, 5
    test.t = "hello"
    MsgBox test.t
End Sub


Error; "Object doesnt support this property or method" at test.t = "hello"

Thanks
Yashwin Kanchan


------------------------------------------------------------------------

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to