Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FSO error?

Status
Not open for further replies.

LuckyDuck528

Programmer
Dec 21, 2004
65
US
Hello All,

I am very new to using VB 6 and I'm having a little problem. I'm updating some code (the original guy is no longer here) and it uses Set fso = CreateObject("Scripting.FileSystemObject") .

The line works perfectly in his version but does not work in mine at all. Honestly the only difference in the two thus far is that I added two check boxes to the .asp page.

I'm getting an error that says "ActiveX Component can't create object" Any suggestions as to what might be going on?

Any help is appreciated! Thank you. [smile]
 
Make sure under Project/References that you have VB Scripting Runtime selected.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Actually, It's "Microsoft Scripting Runtime"

1. Open your project in VB.
2. Click Project
3. Click References
4. Scroll down to Microsoft Scripting Runtime
5. Select it and then click OK
 
If you are using CreateObject you shouldn't actually need a reference to be set.

Heck, given that the OP refers to ASP I have to question whether we are really talking about VB6 ...
 
the reference needs to be set if you are doing early binding.

For example...

Dim FSO as Scripting.FileSystemObject

Set FSO = CreateObject("Scripting.FileSystemObject")


vs.

Dim FSO as Object

Set FSO = CreateObject("Scripting.FileSystemObject")

There are many reasons to do early binding, many of which I couldn't really explain if I wanted to. For me, the biggest advantage is Intellisense.
 
If you call CreateObject(), you're getting late binding. All you've done is strongly type your reference variable, and thus get none of the benefits of early binding.

Instead you'd want to use:

[tt]Set FSO = New Scripting.FileSystemObject[/tt]

But as strongm stated, this looks like ASP and VBScript. I saw nothing in the original post to indicate we're talking about VB6 at all aside from a casual mention that doesn't seem to fit the situation at hand.

VBScript doesn't support strong typing, and doesn't support early binding either.
 
According to MSDN....

"The main difference between declaring a variable of a specific class and declaring a variable of the generic Object class is in how ActiveX binds the variable to the object. When you declare a variable of the generic Object class, ActiveX must use late binding. When you declare an object variable of a specific class, ActiveX uses early binding, which can speed object references. For more information, see "Speeding Object References" later in this chapter."

 
Yeah, wash my mouth out with soap.

The only real difference is that CreateObject() has to look up the UUID at runtime based on the progID.

Sorry to perpetuate misinformation. The important thing is to strongly type the reference variable, as originally stated above.

Mea culpa, for sure.

There is always the issue of vtable binding vs. DispID binding too, but that's another topic.
 
Gee, maybe I just need sleep, I meant ClassID, not UUID - they do look alike though. ;-)
 
To get back on topic, I'd guess the script error originally posted is the result of:
[ul][li]A progID typo,[/li]
[li]The scripting runtime not being installed (old version of MS Scripting installed), or[/li]
[li]My very unfavorite thing, some ani-virus crapware that disables many useful components, usually by munging the registry.[/li][/ul]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top