Python, VB and COM

Discussion in 'Python' started by Nick Leaton, Dec 21, 2004.

  1. Nick  Leaton

    Nick Leaton Guest

    I have a class built as a class library. It makes
    a Test.dll, and I can call this from other VB projects

    class PyTest

    private _name as string

    Public Property Name() as string
    Get
    return _name
    End Get
    Set (byval value as string)
    _name = value
    End Set
    End Property

    End Class

    Then I was expecting to do something like

    import win32Com.client

    pt = win32com.client.Dispatch ("Test.PyTest")
    pt.Name = "fred"
    print pt.Name

    However it doesn't look like the Test.dll is known.
    Any pointers?

    Thanks

    Nick
    Nick Leaton, Dec 21, 2004
    #1
    1. Advertising

  2. Nick  Leaton

    Steve Holden Guest

    Nick Leaton wrote:

    > I have a class built as a class library. It makes
    > a Test.dll, and I can call this from other VB projects
    >
    > class PyTest
    >
    > private _name as string
    >
    > Public Property Name() as string
    > Get
    > return _name
    > End Get
    > Set (byval value as string)
    > _name = value
    > End Set
    > End Property
    >
    > End Class
    >
    > Then I was expecting to do something like
    >
    > import win32Com.client
    >
    > pt = win32com.client.Dispatch ("Test.PyTest")
    > pt.Name = "fred"
    > print pt.Name
    >
    > However it doesn't look like the Test.dll is known.
    > Any pointers?
    >
    > Thanks
    >
    > Nick
    >

    Well, first of all it would have been easier to deal with your specific
    problem if you'd copied the error message you got.

    Exercising my psychic powers. I'll assume you saw something like

    pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

    The best advice I can give is as follows:

    1. Start pythonWin
    2. Bring up Help | PythonWin Reference
    3. Follow the win32com ReadMe link under "Python COM"
    4. Follow the "win32com documentation index" link
    5. Follow the "A quick start to Client Side COM" link.

    The document you reach (yes, accessible, isn't it - I have learned to
    accept that in the open source world some people program and some people
    write documentation, but the two sets rarely coincide) will explain the
    linkages between COM Objects and win32com, and the section under "To
    generate Python sources supporting a COM object" is probably what you need.

    regards
    Steve
    --
    Steve Holden http://www.holdenweb.com/
    Python Web Programming http://pydish.holdenweb.com/
    Holden Web LLC +1 703 861 4237 +1 800 494 3119
    Steve Holden, Dec 21, 2004
    #2
    1. Advertising

  3. Nick  Leaton

    Nick Guest

    Thanks Steve.

    I eventually found the library. Running makepy over the library
    produced the requisite file.

    Its working.

    Help appreciated.

    Nick
    Nick, Dec 21, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    740
  2. Paul Moore
    Replies:
    0
    Views:
    611
    Paul Moore
    Mar 1, 2008
  3. Martin v. Löwis
    Replies:
    0
    Views:
    650
    Martin v. Löwis
    Mar 1, 2008
  4. cnb
    Replies:
    0
    Views:
    279
  5. Replies:
    0
    Views:
    77
Loading...

Share This Page