Results 1 to 6 of 6

Thread: COM object vs interface

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2006
    Posts
    78

    COM object vs interface

    Hi,
    I am trying to expose my classes from VB.NET to VBA. I am currently writing my own interface for each class e.g.:

    Imports System.Runtime.InteropServices
    <Guid("4c42de70-4bdf-11dc-8314-0800200c9a66"), _
    InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
    Public Interface _Optimizer
    ...
    End Interface

    and afterward link the interface with my classes and so they are exposed to VBA.
    There is another possiblilty I just realized in .NET and that is to select a COM class in the wizard (Add>new item>COM class)

    Since I am new to interface programming, what is the difference? It seems that I do not have to write any interface at all with the second method.
    It would be great if someone can elaborate this.
    Thanks

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: COM object vs interface

    What kind of .NET project (VS 2003?) do you start with to create a COM Object creatable using CreateObject?

    Thanks!

    Dave
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2006
    Posts
    78

    Re: COM object vs interface

    Hi Dave,
    I use VS2005. I am not sure what you mean by createobject. I click with the right mouse button on my vb project and than (Add>new item>COM class)

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: COM object vs interface

    Visual Studio automatically creates all of the necassary interfaces when you create a COM class.

  5. #5
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: COM object vs interface

    Does it have to be a special type of project? Does this work with 2003?
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: COM object vs interface

    The ComClass is new in 2005.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width