Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 2nd, 2008, 02:04 PM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
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.

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 With Quote
  #2 (permalink)  
Old July 2nd, 2008, 03:30 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

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.
Code:
      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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:26 PM.


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