View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default how to return a file name

I think I'd use something like:

Dim myFileName as variant
myfilename = application.getopenfilename("Text files, *.xls")
if myfilename = false then
exit sub '??? user hit cancel
end if

msgbox myfilename

And if the layout of the input file never changes (always comma delimited or
same fixed width layout), the next step would be to open the file using those
rules:

Workbooks.OpenText Filename:=myFileName, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
....

I'd record a macro to get the exact details for that .opentext statement.


Monte0682 wrote:

I would like to import a text file and then reurn its file name into a
text box. I have used this:

Application.Dialogs(xlDialogImportTextFile).Show

to open a box to import a file...


--

Dave Peterson