Current working directory for Excel 
Author Message
 Current working directory for Excel

Suppose I have a function (written in VC++) in a DLL, and this function
opens a file whose name is
specified without the full path. If I call this function in a VBA sub
procedure from within Excel,
where does the file have to be in order to be found? Is it Excel's
current working directory, the directory
where Excel.exe is? Somewhere else?

Ed Sowell



Sun, 29 Feb 2004 00:02:05 GMT  
 Current working directory for Excel

Quote:

> Suppose I have a function (written in VC++) in a DLL, and this function
> opens a file whose name is
> specified without the full path. If I call this function in a VBA sub
> procedure from within Excel,
> where does the file have to be in order to be found? Is it Excel's
> current working directory, the directory
> where Excel.exe is? Somewhere else?

FWIW, I would not do it this way, and would advice that you use full paths.  
A dll should be self-contained. Depending on another app's file search order
is _not_ a robust solution.

  -- Dev



Mon, 01 Mar 2004 22:06:08 GMT  
 Current working directory for Excel
I see your point. All I have to do is get the full path right, preferably
without
asking the user for it.

But, still I'd like to know whether it's the DLL or the application using it
that
determines the "current" directory. I do know that the file is not found if it
is placed
in the directory where the .xls file is. This is unfortunate, since that would
be the
natural thing for the user to understand.  So, is there a way VBA can discover
the
directory of a ThisWorkSheet?

Thanks.

Ed Sowell

Quote:


> > Suppose I have a function (written in VC++) in a DLL, and this function
> > opens a file whose name is
> > specified without the full path. If I call this function in a VBA sub
> > procedure from within Excel,
> > where does the file have to be in order to be found? Is it Excel's
> > current working directory, the directory
> > where Excel.exe is? Somewhere else?

> FWIW, I would not do it this way, and would advice that you use full paths.
> A dll should be self-contained. Depending on another app's file search order
> is _not_ a robust solution.

>   -- Dev



Mon, 01 Mar 2004 23:32:12 GMT  
 Current working directory for Excel

Quote:

> So, is there a way VBA can discover
> the directory of a ThisWorkSheet?

You mean ThisWorkbook.Path?

 -- Dev



Mon, 01 Mar 2004 23:55:54 GMT  
 Current working directory for Excel
Sounds good. I'll give it a try.

Many thanks.

Ed

Quote:


> > So, is there a way VBA can discover
> > the directory of a ThisWorkSheet?

> You mean ThisWorkbook.Path?

>  -- Dev



Tue, 02 Mar 2004 00:34:13 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. import excel file from current directory

2. How to find current working directory?

3. How to find current working directory?

4. Help: Current working directory

5. Current working directory variable ?

6. Changing current Working Directory ?

7. Newbie VBS Question: How do I change the current (working) directory

8. Load/use OCX in current working directory

9. How to find current working directory?

10. Getting the Current (working) Directory via Win API

11. Get application directory instead of current directory.

12. Current Directory

 

 
Powered by phpBB® Forum Software