2009/07/09

access2007:パスワードロックしたaccdbのテーブル列挙

Sub ListAccessTables()
Dim catDB As ADOX.Catalog
Dim tblList As ADOX.Table
Dim dbDir As String, Pswd As String

    dbDir = "\\hogehoge\hogehoge.accdb"
    Pswd = "Passw0rd"

    Set catDB = New ADOX.Catalog

    catDB.ActiveConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                             "Data Source=" & dbDir & ";" & _
                             "Jet OLEDB:Database Password=" & Pswd & ";"

    For Each tblList In catDB.Tables
        If tblList.Type = "TABLE" Then
            Debug.Print tblList.Name & vbTab & tblList.Type
        End If
    Next
    Set catDB = Nothing
End Sub

0 件のコメント: