ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Input Box (https://www.excelbanter.com/excel-programming/316497-input-box.html)

MWS

Input Box
 
I have written a macro to retrieve a specific text file from our network and
import it into excel and perform several functions. The scenario has changed
so now the users need to select from several network files, so to
systematically "point" to the one file no longer meets the need. So, can
anyone tell me how to utilize an inputbox, with hopefully some sort of
elipse, so the user can begin the macro to display the input box, via an
elipse, locate/point to the text file and then inport the file via the valued
input box? (it's the input box part I really need help with, since the code
already exist to import and sort the text file data).

Any and all help will be greatly appreciated. Thanks in advance.

Tom Ogilvy

Input Box
 
fname = Application.GetOpenFileName()

Will display the file=Open dialog and allow the user to navigate and select
a file. The fully qualified name of the file (name and path) are returned
to the variable fname (as shown above - the file is not opened) and you can
use that variable to pass the name to the code that does open and process
the file.

See help on GetOpenFileName for additional arguments and options.

If you want to start in a specific directory, before showing the dialog, use
chdrive and chdir to make the start directory the default.

--
Regards,
Tom Ogilvy


"MWS" wrote in message
...
I have written a macro to retrieve a specific text file from our network

and
import it into excel and perform several functions. The scenario has

changed
so now the users need to select from several network files, so to
systematically "point" to the one file no longer meets the need. So, can
anyone tell me how to utilize an inputbox, with hopefully some sort of
elipse, so the user can begin the macro to display the input box, via an
elipse, locate/point to the text file and then inport the file via the

valued
input box? (it's the input box part I really need help with, since the

code
already exist to import and sort the text file data).

Any and all help will be greatly appreciated. Thanks in advance.




MWS

Input Box
 
Thank You Tom - I will try your suggestion.

"Tom Ogilvy" wrote:

fname = Application.GetOpenFileName()

Will display the file=Open dialog and allow the user to navigate and select
a file. The fully qualified name of the file (name and path) are returned
to the variable fname (as shown above - the file is not opened) and you can
use that variable to pass the name to the code that does open and process
the file.

See help on GetOpenFileName for additional arguments and options.

If you want to start in a specific directory, before showing the dialog, use
chdrive and chdir to make the start directory the default.

--
Regards,
Tom Ogilvy


"MWS" wrote in message
...
I have written a macro to retrieve a specific text file from our network

and
import it into excel and perform several functions. The scenario has

changed
so now the users need to select from several network files, so to
systematically "point" to the one file no longer meets the need. So, can
anyone tell me how to utilize an inputbox, with hopefully some sort of
elipse, so the user can begin the macro to display the input box, via an
elipse, locate/point to the text file and then inport the file via the

valued
input box? (it's the input box part I really need help with, since the

code
already exist to import and sort the text file data).

Any and all help will be greatly appreciated. Thanks in advance.






All times are GMT +1. The time now is 07:40 PM.

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