Find path to correct version of Access

D

Doug Leveille

I have a .ade application that runs another .ade file
using the shell command. My problem is that I force the
user to run the initial .ade using Access Runtime 2002 by
the command in their shortcut. I need to make sure they
run the second .ade using Access Runtime 2002 also so
that if they have an older version of Access on their
computer it does not try to run using the older version.

How can I make sure they run the second application using
Access 2002 runtime without hardcoding a path (since each
installation could be using a different location)?
 
P

Paul Overway

Assuming VB Script is installed on the PC, you can use the following
functions:


Function FindMSAccess(Arg)
'Returns the presumed location of Microsoft Access....retail or runtime
'Arg is a integer greater than 7 indicating the version of Access to locate

Dim wsh as Object

On Error Resume Next

Set wsh = CreateObject("Wscript.Shell")

FindMSAccess = StripIt(wsh.RegRead("HKCR\Access.Application." & Arg &
"\Shell\Open\Command\", ""))

End Function

Function StripIt(Arg)
'Removes any command line parameters or quotes from the string

If InStr(Arg, "/") > 0 Then
StripIt = Trim(Left(Arg, InStr(Arg, "/") - 1))
Else
StripIt = Arg
End If

If Left(StripIt, 1) = Chr(34) Then
StripIt = Mid(StripIt, 2)
End If

If Right(StripIt, 1) = Chr(34) Then
StripIt = Left(StripIt, Len(StripIt) - 1)
End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top