Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ActiveX in VB by code

Posted on 2003-03-24
4
Medium Priority
?
157 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
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses
Course of the Month11 days, 8 hours left to enroll

564 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