View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Nick Hodge Nick Hodge is offline
external usenet poster
 
Posts: 1,173
Default auto open text files

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
HIS


"Michael Maloney" wrote in
message ...
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


"Nick Hodge" wrote:

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
HIS


"Michael Maloney" wrote in
message ...
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 Maloney