0

I'm trying to use COM object in following way:

Dim l
l = CreateObject("tst.Ax")
Dim err As Long
Dim st As ULong

Try

   l.AX_hdr(st, err)

   Catch ex As Exception
   MsgBox(ex.Message)
End Try

And I have error

TYPE_E_ELEMENTNOTFOUND

CreateObject works correctly, because this COM object executes some code during initialization (shows messagebox). Object should have method AX_hdr, but I don't have any idea why it can't find it. What else might be wrong? Is there are any method how to retrieve function list from COM object?

1
  • 1
    When you use late binding then you need to have good documentation to know what methods and properties are implemented by the COM server. COM doesn't support Reflection. Contact the owner or author of the component. Commented Aug 10, 2012 at 14:07

1 Answer 1

2

If you add a reference to your COM component, you can instantiate the object using early binding:

Dim l as new tst.Ax

You will then have intellisense for all the method and properties of the component or you can press F2 to do a search using the Object Browser.

You can always remove the reference at a later date if you wish but early binding is usually preferable. I would only use late binding if you have a good reason to or not other option.

Sign up to request clarification or add additional context in comments.

2 Comments

I have added tst.Ax to references and have declared Dim l as new tst.Ax. But when I press dot after l variable I have selection from 5 methods - Equals,GetHashCode,GetType,ReferenceEquals,ToString. This is the same if I do declaration Dim l as new nonExistingObject
Dim l as new nonExistingObject won't compile so I don't know how you can see any methods for it! So my guess is that you haven't declared your object correctly. Use the object browser and/or consult the documentation for your component.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.