How To Reference A Type Library In VBScript

In an Active Server Pages script, you can reference a type library using the METADATA tag. This automatically imports the constants from a DLL. It is usually used for ADO constants and eliminates the need for the adovbs.inc include file.

<!--METADATA TYPE="TypeLib" NAME="Microsoft ActiveX Data Objects 2.6 Library" UUID="{00000206-0000-0010-8000-00AA006D2EA4}" VERSION="2.6" -->

You can do the same thing with a VBScript for Windows Script Host. I like to use these types of scripts for scheduled tasks because you cannot schedule an ASP page to run on schedule. Recently I had to create a VBScript to send out email reminders using the CDO.Message object so I needed to import its type library. The following code allows you to use a type library with Windows Script Host. You must use the WSF file extension because the script will be parsed as XML:

<?xml version="1.0"?>
<job id="script1">
<reference guid="CD000000-8B95-11D1-82DB-00C04FB1625D"></reference>
<script language="VBScript">
<![CDATA[
' script code follows here
]]>
</script>
</job>
This entry was posted in General. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit exceeded. Please complete the captcha once again.