ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Dialog Box to return Selected File Path and Not Open it. (https://www.excelbanter.com/excel-programming/318112-open-dialog-box-return-selected-file-path-not-open.html)

DMS

Open Dialog Box to return Selected File Path and Not Open it.
 
All,
I am trying to find a way for my users to select a file that is going to be
imported so that I can get the filepath. I do not want to open the file.

In other words I have a Text Box that says, "Where is the file located". I
want the user to be able to click a "Search" button and browse for their file
just like they would with the Open Dialog Box. But instead of opening the
file, I just want the filepath to replace the "Where is the file located"
text.

Thanks
DMS

Tom Ogilvy

Open Dialog Box to return Selected File Path and Not Open it.
 
Dim fName as String
fName = Application.GetOpenFileName

will do exactly that. fName will hold the fully qualified name of the file
the user wants to open, selected through the File=Open dialog. It does not
open the file.

--
Regards,
Tom Ogilvy

"DMS" wrote in message
...
All,
I am trying to find a way for my users to select a file that is going to

be
imported so that I can get the filepath. I do not want to open the file.

In other words I have a Text Box that says, "Where is the file located".

I
want the user to be able to click a "Search" button and browse for their

file
just like they would with the Open Dialog Box. But instead of opening the
file, I just want the filepath to replace the "Where is the file located"
text.

Thanks
DMS




DMS

Open Dialog Box to return Selected File Path and Not Open it.
 
That worked great.

Thanks Tom

"Tom Ogilvy" wrote:

Dim fName as String
fName = Application.GetOpenFileName

will do exactly that. fName will hold the fully qualified name of the file
the user wants to open, selected through the File=Open dialog. It does not
open the file.

--
Regards,
Tom Ogilvy

"DMS" wrote in message
...
All,
I am trying to find a way for my users to select a file that is going to

be
imported so that I can get the filepath. I do not want to open the file.

In other words I have a Text Box that says, "Where is the file located".

I
want the user to be able to click a "Search" button and browse for their

file
just like they would with the Open Dialog Box. But instead of opening the
file, I just want the filepath to replace the "Where is the file located"
text.

Thanks
DMS





VBANovice

Open Dialog Box to return Selected File Path and Not Open it.
 
Tom,

what if I only want the path to be remembered because i'm going to loop
through multiple files in the folder?

"Tom Ogilvy" wrote:

Dim fName as String
fName = Application.GetOpenFileName

will do exactly that. fName will hold the fully qualified name of the file
the user wants to open, selected through the File=Open dialog. It does not
open the file.

--
Regards,
Tom Ogilvy

"DMS" wrote in message
...
All,
I am trying to find a way for my users to select a file that is going to

be
imported so that I can get the filepath. I do not want to open the file.

In other words I have a Text Box that says, "Where is the file located".

I
want the user to be able to click a "Search" button and browse for their

file
just like they would with the Open Dialog Box. But instead of opening the
file, I just want the filepath to replace the "Where is the file located"
text.

Thanks
DMS





joel[_601_]

Open Dialog Box to return Selected File Path and Not Open it.
 

fName = Application.GetOpenFileName

'get the path including the last slash
Mypath = left(fName,instrrev(fName,"\"))

'get the path not including the last slash
Mypath = left(fName,instrrev(fName,"\") - 1)


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=173380

Microsoft Office Help



All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com