ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to validate path? --- bValidatePath ("") Then (https://www.excelbanter.com/excel-programming/403738-how-validate-path-bvalidatepath-then.html)

dim

How to validate path? --- bValidatePath ("") Then
 
Hi all,

I have two workbooks called Book1 and Book2. Book1 simply displays a
userform when opened, and when the user clicks 'Ok' it closes Book1 and opens
Book2.

I am going to create a 3rd workbook called Book3. Book3 will be an exact
copy of Book2, but in Book2 all VBA code path's read C:\.... and in Book3 I
will have them reading D:\...

This will be to allow a user to run the program from a hard-drive designated
as C or D. The files are all located in a folder called My Program, and the
user's install instructions are to copy the folder into their Program Files
path. So the total path on the users computer will end up being either:

C:\Program Files\My Program\Book2.xls
or
D:\Program Files\My Program\Book3.xls

When Book1 is open, I want to include in the Button1 Click macro some form
of validation so it can tell if it is located in C:\Program Files\... or
D:\Program Files\.... This will be followed by an IF THEN ELSE, so that if
its in C:\... Then it will open Book2, and if its in D:\... it will open
Book3....makes sense?...any ideas how to get this to work?

I think the code involves 'ValidatePath' something something?

Thankyou.

Jon Peltier

How to validate path? --- bValidatePath ("") Then
 
You would not get an error. Dir(path) would simply return "" if the path
being sought were not available.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"dim" wrote in message
...
Hi,

GTV, I didn't try your way, because if the user has the files installed in
a
harddrive designated 'D', then I think your first If statement would
return
an error since there may be no C drive present at all. But thankyou.

Roger, I tried you way and thus far it's working, but I haven't
transferred
the files onto the other computer with the D drive to test it yet, but it
executes fine on my C drive with the code inserted for both.

Thankyou both for your help. Its appreciated.




dim

How to validate path? --- bValidatePath ("") Then
 
My mistake, thanks for clarifying that.

Jon Peltier

How to validate path? --- bValidatePath ("") Then
 
Actually, a better test than

If SomeString = ""

is

If Len(SomeString) = 0

Because it's quicker to determine the length of one string than to compare
the values of two strings.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"dim" wrote in message
...
My mistake, thanks for clarifying that.





All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com