Solved

Using COM Objects from VB.Net (Object Picker Dialog)

Posted on 2002-06-10
6
441 Views
Last Modified: 2013-11-25
Hi

I want to use the object picker dialog from VB.Net to populate a textbox with a group name. I've never used COM objects before and am having difficulty working out exactly what I need to do.

I found an article on MSDN, rather encouragingly called "Referencing COM Objects from Visual Basic .NET" , but found it very unclear and lacking in detail. I know that I have to import a type library and use the CoCreateInstance function, but I don't know how to find out where the type library is or how to use the function properly.

Please help!

Julia
0
Comment
Question by:JFaulkner
6 Comments
 
LVL 5

Expert Comment

by:rpai
ID: 7067010
To find the TypeLibrary, you could go to OLE View, and select Type Libararies opion.

You need to use:-
ObjectContext.CreateInstance("MyProj.MyClass")
to instanciate the COM object.

The following lines of code are required:-
Implements ObjectControl

Private objctxt As ObjectContext

Private Sub ObjectControl_Activate()
   Set objctxt = GetObjectContext
End Sub
Private Function ObjectControl_CanBePooled() As Boolean
End Function
Private Sub ObjectControl_Deactivate()
   Set objctxt = Nothing
End Sub

In the function where you need to instanciate the object.
objctxt.CreateInstance("MyProj.MyClass")

Hope this helps.
0
 

Author Comment

by:JFaulkner
ID: 7067239
Thanks for replying.

Sorry to ask such basic questions but I'm having difficulty applying your suggestions to my particular scenario (as you've probably gathered I don't don't have a huge amount of programming experience). I'm using IDsObjectPicker to browse active directory. This is part of ADSI and not a standard COM object.

I looked in OLE View but couldn't find anything relating to IDsObjectPicker. Also in your lines of code what should I substitute for ObjectContext, MyClass and ObjectControl; why do you have any empty function (objectControl_CanBePooled); and can I put all this stuff in a normal module ?

Thanks again

Julia
0
 
LVL 5

Expert Comment

by:rpai
ID: 7067454
Are you using VB or C++?

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:JFaulkner
ID: 7069196
VB.Net
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7873487
Hi JFaulkner,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

JFaulkner, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7924952
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now