まりふのひと

Access2010でオブジェクトの一覧表を作りたい...

Microsoft Access2010 を起動した。前回は Access2003 だったから、単純に引いて 7年ぶり‥‥ ぐらい。リボン形式に変わっており、前に進めない...
組んだシステムの内容も全く忘れている。どこに何があるのかさっぱりわからない。そこで、オブジェクトの一覧を作るモジュールから挑戦した。


 参考サイト) Access Tips by pPoy
上記サイトを参考(首っ引き)に、オブジェクトを CSVファイルに書き出すモジュールに四苦八苦した。先が思いやられる...

  

  1. '概要:オブジェクト(テーブル、クエリー、フォーム、レポート、マクロ、モジュール)一覧をCSV出力する。
  2. Sub writeAllModules()
  3. Dim obj As AccessObject, dbs As Object
  4. Dim dsn As Long
  5. Dim strPath As String, strFile As String, strCSVFile As String
  6.  
  7. strPath = Application.CurrentProject.Path
  8. strFile = Application.CurrentProject.Name
  9. strCSVFile = Left(strFile, InStrRev(strFile, ".")) & "csv"
  10.  
  11. dsn = FreeFile
  12. Open strPath & "\" & strCSVFile For Output As #dsn
  13.  
  14. Set dbs = Application.CurrentData
  15. 'AllTables コレクションから検索
  16. For Each obj In dbs.AllTables
  17. If Left(obj.Name, 4) <> "MSys" Then
  18. Write #dsn, strPath, strFile, "テーブル", obj.Name
  19. End If
  20. Next obj
  21. 'AllQueries コレクションから検索
  22. For Each obj In dbs.AllQueries
  23. Write #dsn, strPath, strFile, "クエリー", obj.Name
  24. Next obj
  25. Set dbs = Nothing
  26. '
  27. Set dbs = Application.CurrentProject
  28. 'AllForms コレクションから検索
  29. For Each obj In dbs.AllForms
  30. Write #dsn, strPath, strFile, "フォーム", obj.Name
  31. Next obj
  32. 'AllReports コレクションから検索
  33. For Each obj In dbs.AllReports
  34. Write #dsn, strPath, strFile, "レポート", obj.Name
  35. Next obj
  36. 'AllMacros コレクションから検索
  37. For Each obj In dbs.AllMacros
  38. Write #dsn, strPath, strFile, "マクロ", obj.Name
  39. Next obj
  40. 'AllModules コレクションから検索
  41. For Each obj In dbs.AllModules
  42. Write #dsn, strPath, strFile, "モジュール", obj.Name
  43. Next obj
  44.  
  45. Set dbs = Nothing
  46. Close #dsn
  47.  
  48. End Sub