Excel 97 VBA - CURDIR, not reliable

R

Ricke G

Hi,

I'm using Excel 97 and my whish is to use CURDIR as a way of makin
shure that when having 2 workbooks in a folder somewhere on a drive
will be able to open one from the other.

The problem is that I experience different results from this functio
when having opened a workbook.

P1 = CURDIR
MSGBOX P1

The short example above gives 2 different results in P1 when being use
in for example the "This Workbook" and "WorkBook_Open Sub".

1. Excel - File - Open - Choose - Open: gives always the right result
2. Excel - File - Open - Choose - Close - File - MRUlist: gives alway
the right result
3. Excel - File - MRUlist: gives different result
4. Filemanager - choose file: gives same as with 3.

Looking for an explanation and a way to make 1 - 4 work safely

Rickar
 
T

Tom Ogilvy

If you want to know the location of the workbook being opened

p1 = thisworkbook.Path

curdir is the current directory for the currently default drive. this isn't
necessarily related to the workbook.
 
F

Frank Stone

I have a similar situation but with 3 files. i put up
links on the sheet1 of each file for each of the other
files. when i wanted to open either of the other files, i
just click the link and the other file opened.
on the menu bar>insert>hyperlink. click the file button.
worked for me.
 
Top