?
Solved

ActiveX in VB by code

Posted on 2003-03-24
4
Medium Priority
?
155 Views
Last Modified: 2010-05-01
Hi ,

I have an activex comp. "SMTp.ocx". I have registered it with the OS using "regsvr32 ..." so I can get it in the "Project -> components". Now what is wish is after adding it from components, it appears in the toolbox. But from toolbox I do not want to place it on the form. I want to refer it through code. I tried using the following code:
" Dim smtp1 as smtp
  smtp1.server =  "172.17.4.50"
 ....
"

here when I type  a "." after smtp1, it is showing me a list of properties of that object (of which server is a property - which takes text value as its argument -namely the ip address. But when I run this, it says - "Object variable or with block variable not set". I need to add this comp. thru code as I want to use it from Excel (where I cannot drop it from toolbox).

Thanks in advance,
mohdabbas.burmawala@tatatel.co.in
0
Comment
Question by:contactabbas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 8196259
change to this:

Dim smtp1 as smtp
  set smtp1 = new smtp
 smtp1.server =  "172.17.4.50"


You MUST create an INSTANCE of the class, in order to use the object.  
0
 

Author Comment

by:contactabbas
ID: 8200422
Hi Arthur,

Thanks for your attention. I tried creating the instance by using the statement " set smtp1 = new smtp". It says "Invalid use of NEW keyword". Please help me in this regard.

Thank you in advance,

mohdabbas.burmawala@tatatel.co.in


0
 
LVL 3

Accepted Solution

by:
y2ksw earned 150 total points
ID: 8218481
You cannot instanciate an OCX by code. Convert it to an ActiveX DLL and you will :-)
0
 

Author Comment

by:contactabbas
ID: 8224613
Hi y2ksw,

Thank you for your answer. Your hint was in the right direction and then I found another question in e-e which described the procedure that u hinted at. ( by using "CreateObject").

Thank you very much.

Abbas
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

752 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