Discussion:
Open .txt, Save as .xls from command line
(too old to reply)
Dave Peterson
2004-06-22 02:04:30 UTC
Permalink
If your text file is always the same name, then start a new workbook.
Turn on the macro recorder and record your steps when you do it manually.

Save that workbook as a nice name. You could open that workbook and run the
macro whenever you want to import that text file.

Or you could give the macro the name: Auto_open

Then put a shortcut to that workbook on your desktop. Just double click on the
shortcut, excel will open your file, run the macro and tada!

You could even add:

Thisworkbook.close savechanges:=false

right before the closing "end sub"

and the macro workbook will close (without saving any changes--so don't do this
while you're testing if you haven't saved it!)
I think the subject says it all! I have a txt file that I receive daily that I would like to create a .bat file to open, delimit based on 'space', and save as a xls file.
I'm clueless, any help would be greatly appreciated!
THANKS!
--
Dave Peterson
***@msn.com
graham
2004-06-23 07:01:01 UTC
Permalink
perfect, Thanks.

One additional question if I may:

What if I want to close excel.exe completely, not just the workbook?
Post by Dave Peterson
If your text file is always the same name, then start a new workbook.
Turn on the macro recorder and record your steps when you do it manually.
Save that workbook as a nice name. You could open that workbook and run the
macro whenever you want to import that text file.
Or you could give the macro the name: Auto_open
Then put a shortcut to that workbook on your desktop. Just double click on the
shortcut, excel will open your file, run the macro and tada!
Thisworkbook.close savechanges:=false
right before the closing "end sub"
and the macro workbook will close (without saving any changes--so don't do this
while you're testing if you haven't saved it!)
I think the subject says it all! I have a txt file that I receive daily that I would like to create a .bat file to open, delimit based on 'space', and save as a xls file.
I'm clueless, any help would be greatly appreciated!
THANKS!
--
Dave Peterson
Dave Peterson
2004-06-24 01:53:37 UTC
Permalink
Right before the "End Sub"

application.Quit
'then
End Sub
Post by graham
perfect, Thanks.
What if I want to close excel.exe completely, not just the workbook?
Post by Dave Peterson
If your text file is always the same name, then start a new workbook.
Turn on the macro recorder and record your steps when you do it manually.
Save that workbook as a nice name. You could open that workbook and run the
macro whenever you want to import that text file.
Or you could give the macro the name: Auto_open
Then put a shortcut to that workbook on your desktop. Just double click on the
shortcut, excel will open your file, run the macro and tada!
Thisworkbook.close savechanges:=false
right before the closing "end sub"
and the macro workbook will close (without saving any changes--so don't do this
while you're testing if you haven't saved it!)
I think the subject says it all! I have a txt file that I receive daily that I would like to create a .bat file to open, delimit based on 'space', and save as a xls file.
I'm clueless, any help would be greatly appreciated!
THANKS!
--
Dave Peterson
--
Dave Peterson
***@msn.com
Loading...