Sunday, 5 February 2012

Detecting Access version which created the file

Although it might be so trivial as the title implies; however, it took me really hours deceived that this can be achieved through a straight forward method like looking up the file properties dialog or finding it somewhere on opening this file in the access application.

The outcome for this research was the following windows VB Script for opening an Access file and displaying the original Access version utilized based on a property called FileFormat.


' Initialization
ScriptName = "** Access File Version Detector **"
MsgBox "Please select the Access file...", 0, ScriptName

' Input Access file path
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")
ObjFSO.InitialDir = "c:\"
InitFSO = ObjFSO.ShowOpen
If InitFSO = False Then
    MsgBox "Script Error: Please select a file!", 0, ScriptName
    MsgBox "You selected the file: " & ObjFSO.FileName, 0, ScriptName
End If

' Open Access file specified
Set objAccess = CreateObject("Access.Application")
CurrentFileFormat = objAccess.CurrentProject.FileFormat

' Display the equivalent Access version utilized to create this file
Select Case CurrentFileFormat
    Case 2
MsgBox "It is Microsoft Access 2", 0, ScriptName
    Case 7
MsgBox "It is Microsoft Access 95", 0, ScriptName
    Case 8
MsgBox "It is Microsoft Access 97" , 0, ScriptName
    Case 9
MsgBox "It is Microsoft Access 2000", 0, ScriptName
    Case 10
MsgBox "It is Microsoft Access 2003", 0, ScriptName
    Case 11
MsgBox "It is Microsoft Access 2007", 0, ScriptName
    Case 12
MsgBox "It is Microsoft Access 2010", 0, ScriptName
    Case 13
MsgBox "Not yet! ;)" + Chr(13) & Chr(10) + "It is Unknown file type!", 0, ScriptName
Case Else
MsgBox "It is unknown file type!"
End Select

No comments:

Post a Comment