Visual Basic Errors: Error 429-Identify the Issues

 

Visual Basic Error 429: FileSystemObject Example

Error 429: Can't Create Object - This error is most probably the most dreaded error for VB programmers. It does not tell you much about the problem, it does not tell you much about the solution either. Microsoft has a lot of references to this subject.

This problem has plagued many people for long. Due to unforeseen circumstances that can occur on an individual programmers's machine. For example, initially with the Package and Districution wizard, just by installing a VB application developed by someone would overwrite the common control files and other controls, regardless of which is newer. It has changed a lot now and people prefer other packages like Microsoft Installer (creates MSI files) to PDW. There were problems with registeration of custom controls when distributed via the Package and Deployment Wizard.

The solution for Error 429 can be tricky but is usually very easy. Once you are able to identify where the problem is, you are able to find out why the problem is. For example, the following code would try to write to a file using the filesystemObject:

1     Dim fso As New FileSystemObject
2    Dim fsoStream As TextStream
3    ' Create a text file, and return a reference to a TextStream
4     Set fsoStream = fso.CreateTextFile("c:\somefolder\somfile.txt", True)
5     ' Write to the file
6     fsoStream.WriteLine "This is Line1"
9     fsoStream.Close
10    Set fsoStream = Nothing
11    Set fso = Nothing


But due to some reason, would cause and Error 429!

To resolve, simply download and register the file scrrun.dll from various sites. This file is the runtime for running "Script" file (part of Microsoft Scripting or Windows Scripting host). After downloading, copy the file to your c:\windows\System folder and register it via the regsvr32 tool. To register the component, Click on Start-->run->and type "regsvr32 c:\windows\system\scrrun.dll" without quotes, and press enter. You should receive a message like DLLRegisteration success (or something like it). That's all you need to do. The code will run now.

This was one and probably the simplest example. Using the debugger, you can identify where the error is occuring and then check if the corresponding ActiveX Control's file are installed properly. Sometimes, they're there but get corrupted or may get overwritten by an older version. In that case also the error occurs. Try overwriting the files with the correct ones and re-registering the component. This usually solves the problem. But sometimes, one isn't just lucky...