Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default how to return a file name

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...

  #2   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default how to return a file name

If the file has been opened and is the active workbook, then
ActiveWorkbook.Name returns its name.

If you have a userform where you want to enter that name, then this would
set the text box on the form to the name:

Userform1.Textbox1.Text = Activeworkbook.name

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Monte0682" wrote in message
ups.com...
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...



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default how to return a file name

hello,

my question was:

I have a workbook. I would like to import a text file into one of the
worksheets...When I go Data, get external data, import text file... To
do this I use Application.Dialogs(xlDialogImportTextFile).Show

This will import a file, ask for a delimiter...

But I would like to export a file name that a opened for later
reference... Also I would like to specify into which worksheet I would
like to import...

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
return excel file by email Steve Goodrich New Users to Excel 2 February 25th 09 10:32 PM
How to return over saved file? ghost Excel Discussion (Misc queries) 3 August 2nd 08 02:57 PM
Return file name only from FileDialog PMC1 Excel Programming 2 August 10th 06 05:28 PM
Return File Name to cell ExcelMonkey Excel Worksheet Functions 2 November 22nd 04 09:54 AM
Return to Original File Stephen[_11_] Excel Programming 2 April 22nd 04 12:24 PM


All times are GMT +1. The time now is 12:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"