I have found that the following often does not work and causes a run time
error:
ChDir "..\finance"
whereas ChDir "W:\finance" always works
So how can you determine what the drive letter is (not always W
and insert
it in the ChDir command?
Mervyn,
Bob's question is relevant; it's really not clear where you're getting
the path that you want to find the drive letter of.
However that's not the point of MY post; mine is to warn you that
ChDir "W:\finance" WON'T always work. It will work if your current
drive is W (or whatever), but not if you are moving from one drive to
another. See the on-line help for ChDir:
----------------------
Remarks
The ChDir statement changes the default directory but not the default
drive. For example, if the default drive is C, the following statement
changes the default directory on drive D, but C remains the default
drive:
ChDir "D:\TMP"
------------------
To be completely safe, you have to use a ChDrive statement before the
ChDir one.
But as for your original question... well, we can't go any further
with that until you answer Bob's question. (Though I WILL mention that
if it's just the drive that the current workbook is saved on, you can
get it by just pulling the left hand character (using the Left()
function) from the ActiveWorkbook.Path property.)