views:

307

answers:

2

To find delete folder, in my code in use a varaiable with the following declaration "Dim Folder as Folder". It was working fine for years. But suddenly when exceuting the line "Set folder = fso.GetFolder(strParamPath)" it gives "Type mismatch" I dont know why suddenly this error has come. So I changed the declaration to "Dim Folder as Scripting.Folder" it seems to work. Why it was working fine and now it is not working? Can any one help me?

A: 

It's possible a hotfix/update has done something to the VB libraries/bindings. But without digging into every hotfix MS have released, there's no way to confirm that :-) If you can pin it down to a speific day and find out what updates were installed in the intervening period, that might narrow it down.

Chris J
+6  A: 

Using Scripting.Folder forces VB6 to look in the Scripting type library to find the definition of Folder. If you just write Folder, VB6 first of all looks for a Folder Type or Class in your own code, then looks in turn in each type library in your Project-References and Components dialogues. It will use the first Folder it finds. Using Scripting.Folder is safer and has no drawbacks (see the manual topic ambiguous references), so you only need investigate if you're curious.

Possible explanations:

  • You have somehow installed a new version of one of your references or components and the new version contains a Folder.
  • You have defined a Folder Type or Class in your own code.
  • You've added a new reference or component to the project. It contains a Folder.

Intellisense can help you find out what the Folder is. Type

Dim fol As Folder

and then type

fol.

Intellisense should drop down a list of the members of fol. Select one of them so that Intellisense completes the line for you, something like.

fol.foobar

Now put the cursor on foobar, and choose View-Definition. This should open the Object Browser and take you to the type library that contains the new definition of Folder. Hopefully you will then say "Aha! WonderWidget! And last week I updated WonderWidget to version 59.4001! Which has the new WonderWidgetFolder feature!"

MarkJ
Nicely explained
Ant
Yes, most likely a simple case of namespace congestion.
Bob Riemersma