If....Then statement

  • Thread starter Thread starter jdtivoli
  • Start date Start date
J

jdtivoli

I am trying to create a control button on a form which,
when clicked on, will check to see If a (c:\program
files\microsoft office\office10) folder exists, and if so,
Then run the file named Excel.exe which is in that
folder.

And If the above folder does not exist, I want it to run
the same file from this folder (c:\program files\microsoft
office\office) instead.

This is necessary do to having to use this database with
both Office XP and Office 97 versions.

Help would be appreciated,

Jesse
 
Hi

You would use

ChDrive "C:\
ChDir "\....(path)

If thier is no path it will generate an Err (I believe Err # 76, Path not found). Using Error handeling trap it & do something else like go to another path

Jef
 
But isn't that the command for Change Drive and Change
Directory to...?

I don't want to change the directory that I am currently
in.
I just want it to take one of two courses of action,
based upon whether or not a particular directory exists
on the C: drive.

I know it sounds simple enough, but it sure is beating me
up, trying to get this to work.

Jesse

-----Original Message-----
Hi,

You would use

ChDrive "C:\"
ChDir "\....(path)"

If thier is no path it will generate an Err (I believe
Err # 76, Path not found). Using Error handeling trap
it & do something else like go to another path.
 
jdtivoli said:
I am trying to create a control button on a form which,
when clicked on, will check to see If a (c:\program
files\microsoft office\office10) folder exists, and if so,
Then run the file named Excel.exe which is in that
folder.

And If the above folder does not exist, I want it to run
the same file from this folder (c:\program files\microsoft
office\office) instead.

This is necessary do to having to use this database with
both Office XP and Office 97 versions.

Help would be appreciated,

Jesse

How about:

'---- start of rough code ----
strFolder = "C:\Program Files\Microsoft Office\Office10"

If Len(Dir(strFolder, vbDirectory)) = 0 Then

' Office XP not found ...

strFolder = "C:\Program Files\Microsoft Office\Office"
If Len(Dir(strFolder, vbDirectory)) = 0 Then
' Office 97 not found ...
strFolder = vbNullString
End If

End If

If Len(strFolder) = 0 Then
MsgBox "Neither version of Office is present."
Else
Shell strFolder & "\Excel.exe"
End If

'---- end of code ----
 
Back
Top