ACCESS→SQLServer変換の際に
ACCESSのデータテーブル一覧、リンク先を一斉チェックする必要があったので作成。
エクセルで実行して出力します。
'--------------------------------------------------------------------
Private Sub CHKACCESS()
'参照設定でMicrosoft DAO 3.6 Object Library にチェックを入れておいて下さい。
Dim WB As Workbook
Set WB = ThisWorkbook
Dim WS As Worksheet
Set WS = WB.Worksheets("Sheet1")
Dim StartGyo As Integer: StartGyo = 5
'ACCESS指定
Dim strAdd as String; strAdd = "D:\TEST"
Dim strFile as String; strFile = "test.mdb"
Dim strChkFile As String: strChkFile = strAdd & "\" & strFile
Dim db As DAO.Database, tb As DAO.TableDef
Set db = DBEngine.OpenDatabase(strChkFile, False, True)
Dim No As Integer: No = 1
For Each tb In db.TableDefs
If Left(tb.Name, 4) <> "MSys" Then
WS.Cells(StartGyo, StartRetu - 2) = Now
WS.Cells(StartGyo, StartRetu - 1) = db.Name
WS.Cells(StartGyo, StartRetu) = No
WS.Cells(StartGyo, StartRetu + 1) = tb.Name
WS.Cells(StartGyo, StartRetu + 2) = tb.Connect
WS.Cells(StartGyo, StartRetu + 3) = tb.SourceTableName
No = No + 1
StartGyo = StartGyo + 1
End If
Next tb
db.Close
MsgBox "OK"
End Sub
'--------------------------------------------------------------------
ACCESSからSQLServer 変換 移行 VBA マクロ
0 件のコメント:
コメントを投稿