The Microsoft Scripting Runtime Object Library

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

When you install the Office XP applications, one of the object libraries installed on your system is the Scripting Runtime object library. This object library contains objects that are useful from either Microsoft® Visual Basic® for Applications (VBA) or script, so it is provided as a separate library.

The objects in the Scripting Runtime library provide easy access to the file system, and make reading and writing to a text file much simpler than it is in previous versions.

By default, no reference is set to this library, so you must set a reference before you can use it. If Microsoft Scripting Runtime does not appear in the References dialog box (Tools menu), you should be able to find it in the Windows system directory as Scrrun.dll.

The top-level objects in the Scripting Runtime object library are the Dictionary object and the FileSystemObject object. To use the Dictionary object, you create an object variable of type Dictionary, then set it to a new instance of a Dictionary object:

Dim dctDict As Dictionary

Set dctDict = New Dictionary

To use the other objects in the Scripting Runtime library in code, you must first create a variable of type FileSystemObject, and then use the New keyword to create a new instance of the FileSystemObject, as shown in the following code fragment:

Dim fsoSysObj As FileSystemObject

Set fsoSysObj = New FileSystemObject

You can then use the variable that refers to the FileSystemObject to work with the Drive, Folder, File, and TextStream objects.

The following table describes the objects contained in the Scripting Runtime library.

Object Collection Description
Dictionary   Top-level object. Similar to the VBA Collection object. Use this to store data key item pairs.
Drive Drives Refers to a drive or collection of drives on the system.
File Files Refers to a file or collection of files in the file system.
FileSystemObject   Top-level object. Use this object to access drives, folders, and files in the file system.
Folder Folders Refers to a folder or collection of folders in the file system.
TextStream   Refers to a stream of text that is read from, written to, or appended to a text file.

See Also

Working with Files | Returning Files from the File System | Setting File Attributes | Logging Errors to a Text File | The Dictionary Object