Home All Groups Group Topic Archive Search About

working with a com interface

Author
25 Nov 2007 4:23 AM
barcrofter
Im having vb6 transitional problems.  Im trying to build an automation
interface to lotus wordpro in vb.net and after adding the reference to
wordpro to my project I find that I get only the interface.
e.g this approach works, where I create an object:

        Dim wpApp As Object
        wpApp = CreateObject("wordpro.application")

but I lose all the advantages of the type definition

But this alternative doesnt work:

        Dim wpapp As Wordpro.WPApplication


gives me an error that Wordpro.WPApplication is an interface

         Dim i% = lstFiles.SelectedIndex
        Dim fn$ = lstFiles.Items(i)
        Try
            wpApp.OpenDocument(fn)
            wpApp.ActiveDocWindow.visible = True
        Catch ex As Exception
            MsgBox("Open failed on document " + fn + " for " +
ex.Message)
        End Try

Author
25 Nov 2007 4:38 AM
Stephany Young
You are only declaring a variable of <type>.

You need to instantiate it as well.

  Dim wpapp As New Wordpro.WPApplication
               ===


Show quoteHide quote
"barcrofter" <jd.p***@gmail.com> wrote in message
news:37f1fe94-85f6-44cf-ba6e-d9e0b90459f8@s12g2000prg.googlegroups.com...
> Im having vb6 transitional problems.  Im trying to build an automation
> interface to lotus wordpro in vb.net and after adding the reference to
> wordpro to my project I find that I get only the interface.
> e.g this approach works, where I create an object:
>
>        Dim wpApp As Object
>        wpApp = CreateObject("wordpro.application")
>
> but I lose all the advantages of the type definition
>
> But this alternative doesnt work:
>
>        Dim wpapp As Wordpro.WPApplication
>
>
> gives me an error that Wordpro.WPApplication is an interface
>
>         Dim i% = lstFiles.SelectedIndex
>        Dim fn$ = lstFiles.Items(i)
>        Try
>            wpApp.OpenDocument(fn)
>            wpApp.ActiveDocWindow.visible = True
>        Catch ex As Exception
>            MsgBox("Open failed on document " + fn + " for " +
> ex.Message)
>        End Try