command to import a file into excel

V

vikram

i have made an excel file wherein i hve a command button and when
click that command button, a common dolog box opens and i select a tex
file, now i have selected a text file, i want to import it int
excel,,how would i do that

i have attached the file...


please let me know thank

Attachment filename: vikrama.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=54352
 
T

Tom Ogilvy

assume the variable fname holds the fully qualified path as returned by your
common dialog.

Workbooks.Open Filename:=fname

If you want special treatment of the text file, look at
Workbooks.OpenText Filename:=fname, . . . additional arguments - see help .
.. .
 
T

Tom Ogilvy

Sorry, if you want to import it into an existing document, turn on the macro
recorder while you manually do

Data=>Get External Data => Import Text file

and import a text file.

Then turn off the macro recorder and replace the hardcoded file name with
the variable fName or whatever variable holds the fully qualified name of
the file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top