?
Solved

Getting the version of Office (Access), if installed

Posted on 2002-07-04
7
Medium Priority
?
173 Views
Last Modified: 2010-05-02
How can I get the version of an installed MS Office, if it exists, that is...

Up to now I'm checking the following reg key exists, assuing this will only be there if office is installed:
HKEY_LOCAL_MACHINE\Software\Microsoft\Office

I've seen some other answers to this question in PAQs, but I'm not going to accept those answers if they are re-submitted for my question.

E.G.:
(assuming there's already a this line of code: "Dim A as Access.Application")

Checking A.Version doesnt work - there is no version property of that object.

Checking A.CurrentDB.Version - nope!, there has to be a database open and I can't open it if they have Access 97 (which is why I want this version checker :)

I think that's all... thanks! :)
SiM99
0
Comment
Question by:SiM99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 17

Expert Comment

by:inthedark
ID: 7129843
Do you have VB6?
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7129876
' Set a reference to MS DAO V 3.6+

' Using this option does not need to open a database

msgbox FindInstalledVersion()


4.0 = 2000
3.0 = 95/97
2.0 = Access V2
1.1 = Access V1.1
1.0 = Access V1.0

Hope this helps.........


Function FindInstalledVersion()

Dim ver$
dim tmp$
dim db=dao.database
tmp$ = App.Path + "dummy.mdb"
Set db = Workspaces(0).CreateDatabase(tmp$, dbLangGeneral)
ver$ = db.Version
db.Close
set db=nothing
DoEvents
Kill tmp$
FindInstalledVersion=ver$

End Function
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7129914
dim db As DAO.database ' would be better than dim db=dao.database

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 44

Accepted Solution

by:
bruintje earned 400 total points
ID: 7130026
don't know if you seen this one already i didn't take it from the PAq's because i don't use them anyway ;)

---------------------------------
From Jake Marx

An alternative would be to look at the CurVer registry key for Access.  Here's some code that should get the version number from the registry for you.  If the function fails (most likely because the user doesn't have Access installed), it will return 0.



Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const ERROR_SUCCESS = 0&
Public Const gsACCESS_KEY As String = "Access.Application\CurVer"
Public Const gsACCESS_VALUE As String = vbNullString

Public Declare Function RegCloseKey Lib "advapi32.dll" _
 (ByVal hKey As Long) As Long

Public Declare Function RegOpenKey Lib "advapi32.dll" _
 Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey _
 As String, phkResult As Long) As Long

Public Declare Function RegQueryValueEx Lib "advapi32.dll" _
 Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName _
 As String, ByVal lpReserved As Long, lpType As Long, lpData _
 As Any, lpcbData As Long) As Long

Public Function nGetAccessVersion() As Integer
    Dim hCurrKey As Long
    Dim lResult As Long
    Dim lValType As Long
    Dim lValBufferSize As Long
    Dim sValue As String
    Dim nNullCharPos As Integer

    lResult = RegOpenKey(HKEY_CLASSES_ROOT, gsACCESS_KEY, _
     hCurrKey)
    lResult = RegQueryValueEx(hCurrKey, gsACCESS_VALUE, _
     0&, lValType, ByVal 0&, lValBufferSize)

    If lResult = ERROR_SUCCESS Then
        sValue = Space$(lValBufferSize)
        lResult = RegQueryValueEx(hCurrKey, gsACCESS_VALUE, _
         0&, 0&, ByVal sValue, lValBufferSize)
        nNullCharPos = InStr(sValue, vbNullChar)
        If nNullCharPos Then sValue = Left$(sValue, _
         nNullCharPos - 1)
        nGetAccessVersion = CInt(Right$(sValue, Len(sValue) - _
         InStrRev(sValue, ".")))
    End If
    RegCloseKey hCurrKey
End Function
------------------------------------

HAGD:O)Bruintje
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7130035
maybe this could help:

Private Sub Form_Load()
On Error Resume Next
Dim a As Object
Set a = CreateObject("access.application")
If Err.Number <> 0 Then
    MsgBox "Access is not installed"
    Err.Clear
Else
    MsgBox a.dbengine.properties("version")
    a.quit
    Set a = Nothing
   
End If
   
End Sub
0
 
LVL 1

Author Comment

by:SiM99
ID: 7156570
Ive given each method a test

From inthedark's method, I get 4.0, which as he said is access 2000. That works, but I didn't want to open a database because that's extra processing time (aswell as the fact it wouldnt open in 97) so creating one will also take that extra time... if not more.

The code from Richie_Simonetti gave 3.6, and I have absolutely no idea what that would mean :)

bruintje's mention of the registry value in HKEY_CLASSES_ROOT was really what I was looking for.

Thanks for the feedback.
Sorry it took so long for me to accept an answer, havent looked at EE for a while.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7156969
Thanks for your reply. it is nice to see another comment from asker when question is finished.
Cheers
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question