Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 2nd, 2008, 02:04 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default Search for Application Path

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.


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")
      Unload Me
  ' accObj.CloseCurrentDatabase
  ' accObj.Quit
      Set accObj = Nothing
      MsgBox "Username or Password is incorrect."
   End If
End If
End Sub

Old July 2nd, 2008, 03:30 PM
Friend of Wrox
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

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.

Similar Threads
Thread Thread Starter Forum Replies Last Post
using app.path in database path and filename kd8con VB Databases Basics 2 October 25th, 2006 11:45 AM
The virtual path maps to another application deeptisingh20 ASP.NET 1.0 and 1.1 Basics 2 August 8th, 2006 07:05 AM
Application path Dsypher C# 2005 1 October 8th, 2005 07:31 AM
Convert logical path to absolute path zoostar J2EE 1 April 15th, 2005 10:36 AM
Getting the application path xgbnow Visual C++ 6 October 24th, 2003 06:30 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.