Getting the full path when from a File Open Dialog Box

R

Ric Payne

Is there an easy way to obtain the full path for a file from an File
Open Dialog Box?
Thank you in advance.
Ric Payne
 
R

Rob Bovey

Ric Payne said:
Is there an easy way to obtain the full path for a file from an File
Open Dialog Box?

Hi Ric,

I'm not sure exactly what you're asking. When you use the
Application.GetOpenFilename method to prompt the user to select a file, it
returns the full path and filename of whatever file the user selects. If
this isn't what you're looking for, can you be a bit more specific?

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
R

Rob Bovey

Hi Ric,

If the user uses the built-in File/Open dialog to open a file, the
current directory is automatically changed to the path the file was opened
from. If you want to see what that directory is, you can get the full path
and file name for any previously saved workbook using:

Workbooks("MyBook.xls").Path

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
R

Ric Payne

Thank you again Rob.
Because I am only opening the file to get some data then closing it
again i wanted to capture the path so that when i subsequently saved
it i would go to the directory from which i originally got it and that
directory may not be the default directory which contains other data
files.
I figured that one way to do that was immediately after using the file
open or save dialog to cath the path as follows

NameOfPath=Left(FileName,InStrRev(FileName,"\"))

Where FileName is the name of the xls file that i opened.

That strips out the file name and leaves me with the path. Do you see
any problems with this?
 

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