View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Import text file contents based on path

turn on the macro recorder and do Data=Import External Data

when the data is in turn off the macro recorder

Get the filename with

fName = Application.GetOpenFileName()

see help on GetOpenFileName for options on the filter

this function returns the fully qualified path of the selected file

use FName in the code you recorded to direct it at the file you want.

--
Regards,
Tom Ogilvy


"crazybass2" wrote in message
...
I need code that will prompt the user (via browse window) to choose a

file.
I then want to import the contents of the specified file into a sheet.

The
files will all be text files, but do not have a .txt extension. I don't

want
the user to have to Data-Import External Data