Wrong current directory

A

Alan

I have an Excel Workbook that is saved in a directory. It contains
a VBA macro with the following code:

Dim StartDir As String
StartDir = CurDir
MsgBox (StartDir)
.. . .

However, it says that the current directory is another one, not
the one in which the Workbook is saved.

Why would it do this?

I am new to VBA. Thanks, Alan
 
G

Gary Keramidas

maybe your file is on a different drive, i don't know because you didn't give
many details.

try this if you're looking for the current directory on another drive, such as
D, in this case.

StartDir = CurDir("D")
 
T

Tim Williams

Thisworkbook.path

will give you the folder where the workbook is saved. CurDir is something
else.

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top