Solved

Visual Basic DLL call from VBScript???

Posted on 2004-09-01
7
743 Views
Last Modified: 2013-11-25
Hi,

Does anyone know why a component (ActiveX EXE) created in Visual Basic 6.0 sp5 cannot be run directly from within IE6 or even directly from a .vbs file. OK, I know that IE6 is down to security reason, but what about the .vbs file?

I have code similar to this, where my main application is a ActiveX EXE and it exposes various methods, functions, properties and events. I have written similar code in VB6.0 and it works without any problems. If I run it within either one i.e. IE6 or .vbs, it tells me that my property does not exist when I know it does.

Code sample:

Dim myObj

Set myObj = CreateObject("MyApp.CMyApp")

msgbox MyApp.UID (This works!)
msgbox MyApp.Search.Text("My Field") = "TEST" (This does not work. Tells me that the property does not exists i.e. error 438)

yet this one will work, ok, I know they are different, but it still does not explain why the above work in vb6

msgbox MyApp.Search.Text.Count ' return 6

Appreciate any feedback.

Thanks.

T.
0
Comment
Question by:taf
  • 2
7 Comments
 
LVL 11

Expert Comment

by:SweatCoder
ID: 11954752
i've called dll's from vbs and it works fine. is the dll registered?
0
 
LVL 8

Accepted Solution

by:
mladenovicz earned 250 total points
ID: 11954846
You should use myObj instead of MyApp

Dim myObj

Set myObj = CreateObject("MyApp.CMyApp")

msgbox myObj.UID
msgbox myObj.Search.Text

........

Set myObj = Nothing
0
 

Author Comment

by:taf
ID: 12032359
Hi,

It is definitely registered as I mentioned, it can access the first level of the properties contains in my object i.e. obj.count will work, but not obj.lines.count for example.

Remember as well it is not a dll but a ActiveX Server (.EXE), so maybe that is the problem.

As for my naming convension, this was just for the sake of the example. I would never user MyApp or MyObj either way. That's not really the type of feedback I was looking for????

Thanks.

T.
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12563908
I did not talk about your naming convention.  Your code uses variable that is not declared

Set myObj = CreateObject("MyApp.CMyApp")   '-- here is MyObj

msgbox MyApp.UID (This works!)
msgbox MyApp.Search.Text("My Field") = "TEST" '-- here is MyApp, but you declared myObj
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

708 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