ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Public Const on a Drive (https://www.excelbanter.com/excel-programming/304166-public-const-drive.html)

MD

Public Const on a Drive
 
Good day all,

I have a series of excel files (all inter-linked) located in a folder called
"MasterFolder". Winthin that MasterFolder, I have other secondary folders
(Folder1, Folder2...).

Since all the files within these folders are all linked by macros, I use
Public Const to identify my directories instead of having to retype the full
path. (ie c:\MasterFolder\Folder1\... I would have a :
Public Const MainDrive = "C:\"
Public Const PCFolder = "MasterFolder\Folder1\" etc.).

So I could do things like open file MainDrive + PCFolder + "file.xls"
(c:\MasterFolder\Folder1\file.xls)

The thing is if I install this program on a drive other than the C: drive, I
have to go and modify my Public Const formula to fit the drive it is running
on.

So, Is there a way to formulate my path in a way that I won't declare the
drive but instead it will detect what drive the MfasterFolder is in and use
that drive as it's "drive" by default when my MainDrive constant is
declared.

Regards,

Michel




Bryan[_10_]

Public Const on a Drive
 
Why not use a property instead. i.e.

Public Property Get MainDrive() As String
MainDrive = Left(Environ("windir"), 3)
End Property


"MD" wrote in message
.. .
Good day all,

I have a series of excel files (all inter-linked) located in a folder

called
"MasterFolder". Winthin that MasterFolder, I have other secondary folders
(Folder1, Folder2...).

Since all the files within these folders are all linked by macros, I use
Public Const to identify my directories instead of having to retype the

full
path. (ie c:\MasterFolder\Folder1\... I would have a :
Public Const MainDrive = "C:\"
Public Const PCFolder = "MasterFolder\Folder1\" etc.).

So I could do things like open file MainDrive + PCFolder + "file.xls"
(c:\MasterFolder\Folder1\file.xls)

The thing is if I install this program on a drive other than the C: drive,

I
have to go and modify my Public Const formula to fit the drive it is

running
on.

So, Is there a way to formulate my path in a way that I won't declare the
drive but instead it will detect what drive the MfasterFolder is in and

use
that drive as it's "drive" by default when my MainDrive constant is
declared.

Regards,

Michel







All times are GMT +1. The time now is 11:27 AM.

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