browse to find file

S

Steph

Hello. Is it possible to have excel via vba allow a user to browse through
folders (like when a user clicks on File>Open), but instead of actually
opening the file they select, I would like the file to be copied to a
specified location (variable called infopath) AND also have the name of the
file selected inserted into cell A1?

Thanks!
 
T

Tom Ogilvy

fname = Application.GetOpenfileName

This will display the fileopen dialog and return the name and path of the
file selected (or typed in). It will not open the file. You can then use
the results to copy the file. The dichotomy here is that it is unclear what
file is being copied.
 
B

Bob Phillips

Check out GetOpenFilename in VBA help to show how to browse a file.

If you open it, you can then saveas to the new location and close it
immediately, after saving the name

ActiveWorkbook.SaveAs Filename:= ....
ThisWorkbook.Range("A1").Value = ActiveWorkbook.FullName
ActiveWorkbook.Close

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
S

Steph

Thanks guys!

Bob Phillips said:
Check out GetOpenFilename in VBA help to show how to browse a file.

If you open it, you can then saveas to the new location and close it
immediately, after saving the name

ActiveWorkbook.SaveAs Filename:= ....
ThisWorkbook.Range("A1").Value = ActiveWorkbook.FullName
ActiveWorkbook.Close

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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