| 開いている MDB ファイルのディレクトリの取得 |
|
対象バージョン : 97, 2000, 2002, 2003, 2007
最終更新日 : 2007/02/12
( オリジナル作成日:1996/12/08 )
概 要
現在開いている MDB ファイルのディレクトリ(フォルダ)を得る方法です。
手 順
次のユーザー定義関数を作成します。
【97】
Function GetCurrMDBDir() As String
Dim db As DATABASE
Dim FullPath As String
Dim ilop As Integer
Set db = CurrentDB()
FullPath = db.Name
For ilop = Len(FullPath) To 1 Step -1
If Mid(FullPath, ilop, 1) = "\" Then Exit For
Next
GetCurrMDBDir = Left(FullPath, ilop)
End Function
【2000 以降】 ○MDB・ACCDB Function GetCurrMDBDir() As String Dim db As DAO.DATABASE Set db = CurrentDB() GetCurrMDBDir = Left(db.Name, Len(db.Name) - Len(CurrentProject.Name)) End Function ○MDB・ACCDB, ADP CurrentProject オブジェクトの Path プロパティで取得することも可能です。 Function GetCurrMDBDir() As String GetCurrMDBDir = CurrentProject.Path End Function
改定履歴