Trying to Determining Microsoft Access version

brownpa

New member
Joined
Jun 16, 2006
Messages
4
Programming Experience
1-3
I am trying to write a program that will search our users local drives to find all access databases that are still Ms Access 97 versions. They have access databases that could be Access 97 or Access 2002. I want to upgrade the Access 97 databases to Access 2002. However, I don't want to open each database to determine what version it is. I tried to right some test code below, however, this appears to works only on .exe files. Any help in this matter, would be greatly appreciated.


Sub GetFileVersion()
' Get the file version for .mdb file.
Dim myFileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo("c:\ChargeLog.mdb")
' Print the file name and version number.
Me.txtSearchFiles.Text = "File: " & myFileVersionInfo.FileDescription & ControlChars.Cr & _
"Version number: " & myFileVersionInf
End Sub
 
This is part of a c# file i found, i've converted it to vb.net. I hope it will be of help it's just that i'm on my way out and haven't got time to go through it fully. I know it's for MS Word but i don't see why i cant be used for access too.


VB.NET:
Imports System
Imports Microsoft.Office.Core
Imports Extensibility
Imports System.IO
Imports System.Collections
Imports System.Runtime.InteropServices
 
 
   Public Sub OnConnection(ByVal application As Object)
)
   Dim version As String
   Dim nonRibbonApp As Boolean=False
   'assign application and add-in instance objects
  [COLOR=red] applicationObject = CType(application, Microsoft.Office.Interop.Word.Application)
   addInInstance = CType(addInInst, Microsoft.Office.Core.COMAddIn)[/COLOR]
[COLOR=red] 'retrieve Word version
   version=applicationObject.Version[/COLOR]
[COLOR=red] 'account for any possible text in the Word version string that could fail the 
   'detection of the correct version. Get only the major version number (12)
   version=version.Split(" "c)(0).Split("."c)(0)[/COLOR]
   'check if the major version number is < 12. We need try-catch as this could
   'fail if version is not a pure number
end sub

I've highlighted the bit that MAY be of interest to you in red.
 
Thank you for your help. I cannot get the above code to work. It appears that I need to install Primary Interop Assemblies (PIAs), which I did. However, I still cannot get it working. I'm new to PIA's so I'm struggling here. By looking over the code, however, It looks like this will get me the version of Acess that is on a users computer. I know that each of my users have Access 97 and Access 2002 installed on their computer. What I need to know is which of the .mdb files is Access 97 so I can convert the files to Access 2002. We would like to remove Access 97 from our users computers. Any help in this would be greatly appreciated.
 
Back
Top