auto open text files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Exploring whether I can create a text file with embedded VBA code that will
allow file to be openned in excel.

Thanks in advance.
 
Michael

Not sure what you mean. You can save a text file as .csv and it will open
automatically in Excel. You can also record/write a macro opening any other
type of text file with the text import wizard, saving this code to your
personal.xls. This would then always be available to re-run every time XL
was opened

VBA embedded in a text file...no

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
Re: VBA embedded in a text file...no

follow-up question:

Since name of text file will change every time, can a macro (VBA) be created
to open to most recent (date/time stamp) file in a particular folder?

Thanks again. Mike
 
Michael

Does it have to be totally automated in this way. If you just want a
different file fed into the macro each time then at the top (below Sub
xxxxx()) put these lines

Dim sFile As String
sFile = Application.GetOpenFilename(, , "Select an import file")

Then replace the file name you have in the macro with sFile. (Take out the
"" too)

This will now present a box similar to the file open box. It takes the
selection into the sFile variable and uses that in your code. You can
further refine the files it shows in the open dialog box but currently it
shows 'All Files (*.*)'

Let me know how you get on



--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 

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

Back
Top