Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Paths 2

Status
Not open for further replies.

Cpreston

MIS
Mar 4, 2015
969
0
16
GB
Hi

I have this code below which works ok in 32bit windows

Private Sub runreport_Click()
Dim myPath As String
myPath = "C:\Program Files\Crystal Delivery\crystaldelivery.exe"
Call Shell(myPath, 1)
End Sub


However, we now have a new computer running 64bit windows and the path is now in a different place and the code fails and highlights
Call Shell(myPath, 1)

This is because the path on the 64bit computer is different. Is it possible to have 2 different mypath = in the code and if so how do I add it in.

Thanks
 
You could try something like:

Code:
mypath = ......  '32bit location
if dir(mypath) <> '' then 
    call .....
else
    mypath = .....  '64bit location
    if dir(mypath) <> '' then
        call ....
    else
       msgbox "error message"
etc....
 
Hi

I have the code (sorry not experience coder) like this, which is incorrect as I am getting a compile error:syntax error, I think it is the mypath area, how should it look please. I will keep trying in the meantime with the code.

Private Sub runreport_Click()
Dim myPath As String
If dir(mypath) <> "C:\Program Files\Crystal Delivery\crystaldelivery.exe"
Call Shell(myPath, 1)
Else
If dir(mypath) <> "C:\Program Files86\Crystal Delivery\crystaldelivery.exe"
Call Shell(myPath, 1)
Else
msgbox "Could not find location"

End IF
End Sub
 
When you post your code here, do not re-type it, just copy-and-paste the code.
softhemc's sample should look like this:

Code:
Private Sub runreport_Click()
Dim myPath As String

myPath = "C:\Program Files\Crystal Delivery\crystaldelivery.exe"

If dir(myPath) <> "" Then
    Call Shell(myPath, 1)
Else
    myPath = "C:\Program Files86\Crystal Delivery\crystaldelivery.exe"
    If dir(myPath) <> "" Then
        Call Shell(myPath, 1)
    Else
        MsgBox "Could not find location"
    End IF
End If

End Sub

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
I used ..... as placeholders for you to replace with the relevant paths or your existing code as appropriate because you said your code worked on 32bit systems and you simply needed to determine which path to use.

Essentially my code (which Andy has kindly fully expanded) says:
1:[tab]Check to see if the 32bit file exists - if the Dir function returns an empty string (') then file not found
2:[tab]If the file is found at step 1 (i.e. Dir does not return ') then Call with that path
3:[tab]The same as step 1 but testing for the 64bit file
4:[tab]The same as step 2 but using the 64bit file
5:[tab]Neither the 32bit nor the 64bit file was found - Dir returned ' on both files so report the error.
 
For some reason two consecutive single quotes in the above reply are being replaced by just one. This is a "feature" of the website.

Please read two single quote characters for each one shown above!!!!!
 
Hi

Thanks for the reply's, all working now.

Thanks for the help much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top