|
Subject:
|
Search for Application Path
|
|
Posted By:
|
jmss66
|
Post Date:
|
7/2/2008 2:04:36 PM
|
Our company has several workstations with Office 2007 and some have Office 2002. How do I check a workstation if it has 2007 or 2002. I am running a program that calls an MSACCESS.EXE database. My program below has a code
application = "C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE"
This works if it's office 2002. What about 2007? It has a different path.
Thanks
Private Sub cmdLogin_Click()
Set rsUser_Account = New ADODB.Recordset mysql = "SELECT * FROM User_Account WHERE User_Name = '" & txtUsername.Text & "'" rsUser_Account.CursorType = adOpenDynamic rsUser_Account.LockType = adLockOptimistic rsUser_Account.Open mysql, adoBenConn
If Not rsUser_Account.EOF Then If rsUser_Account!User_Password = txtPassword.Text Then Dim accObj As Access.application ' This is the default location of Access application = "C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE" ' Use the path and name of a secured MDB strPath = rsUser_Account!Application_Path & rsUser_Account!Application_Name x = Shell(application & " " & Chr(34) & strPath & Chr(34)) Set accObj = GetObject(, "Access.Application") Me.Hide Unload Me ' accObj.CloseCurrentDatabase ' accObj.Quit Set accObj = Nothing Else MsgBox "Username or Password is incorrect." End If End If End Sub
|
|
Reply By:
|
BrianWren
|
Reply Date:
|
7/2/2008 3:30:02 PM
|
Create an .INI file for the app, and enter the proper info into it.
Then, when the app starts, it will retrieve the info from the .INI.
Don't use CHR(34). In a vb string you use a pair of " to resolve to a single one in the resultant string.
s = """" will set s to one double-quote mark. x = Shell(application & " """ & strPath & """") There also might be a registry entry you can access. Also, perhaps you could search downward from the most recent office config. If not found then look for the one before, and so on, and so on.
|