• The code below will give you a working example. It will loop through all files within the given folder. When the file is of a type: "Microsoft Access Database" then an ADODB connection is setup to that file. When an errors occurres a message is displayed stating the filename and the error message. Else the message is displayed stating the file is accessible.

    strPath = "{your folder path here}"

    Set objConn = CreateObject("ADODB.Connection")

    ' create objects to the file system

    Set objShell = CreateObject("Shell.Application")

    Set objFolder = objShell.Namespace(strPath)

    Set colItems = objFolder.Items

    ' ignore errors and proceed to the next line

    On Error Resume Next

    ' loop through each file

    For Each objItem in colItems

    ' check the file type

    if objItem.type = "Microsoft Access Database" then

    ' build the connection string and try to open the file

    strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & "\" & objItem.name & ";"

    objConn.Open strConnect

    ' check for errors

    If Err.Number = 0 Then

    ' no error: replace the line below with the code you need to perform on an accessible database

    wscript.echo objItem.name & " can be opened." & vbCrLf

    else

    ' error occurred: remove this ELSE block if you don't want any messages regarding inaccessible databases

    wscript.echo objItem.name & " is inaccessible." & vbCrLf & err.description & vbCrLf

    end if

    ' reset error

    Err.Clear

    end if

    Next

    wscript.echo "End script"

    Replace the messages (ECHO commands) with the applicable code suitible to your needs.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **