Link to home
Start Free TrialLog in
Avatar of contactabbas
contactabbas

asked on

ActiveX in VB by code

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
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

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.  
Avatar of contactabbas
contactabbas

ASKER

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


ASKER CERTIFIED SOLUTION
Avatar of y2ksw
y2ksw

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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