0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ACCDEで実行されているかどうかを調べる方法

Posted at

VBA実行時にACCDEファイルで実行されているかどうかを判定する方法

  • CurrentDb.Properties("MDE") で判定する方法
  • 拡張子で判定する方法

Access2013で確認済み。

CurrentDb.Properties("MDE") で判定する方法

ACCDEが作成されるときに
CurrentDb.Propertiesに MDE というPropertyが追加され
値には T が入っているようだ。
その有無でACCDEかどうかが判定できそう。

Public Function IsAccde() As Boolean
    
    Dim result As Boolean
    
    On Error Resume Next
    result = (CurrentDb.Properties("MDE") = "T")
    On Error GoTo 0
    
    IsAccde = result
    
End Function

拡張子で判定する方法

以下は単純に拡張子が "accde" かどうかで判定している。

Public Function IsAccde() As Boolean
    
    Dim fso As Object
    Dim myExtension As String
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    myExtension = fso.GetExtensionName(CurrentProject.FullName)
    Set fso = Nothing

    IsAccde = (StrConv(myExtension, vbLowerCase) = "accde")
    
End Function

使い方

    If IsAccde Then

        ' ACCDEのときに行う処理とか
        
    End If
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?