convert *.CSV to *.XLS from DOS?

  • Thread starter Thread starter Guvee
  • Start date Start date
G

Guvee

Hi,
I need to get a CSV file imported into Excel, and format the page to
landscape, at 75% reduction - all with one click...

Any suggestions?

The O/S is Win98se, and it is Excel'97. I am really hoping for a
command line reference or utility.. I am currently exploring the
following routine:
1. PIF executes batch file
2. Batch file locates random *.csv in folder1 and gives it static
name; moves original CSV to archive folder; moves static.csv to temp
folder
3. batch then "starts" Excel, opens (formatted) empty template,
imports static.csv via startup macro..?

I know nothing about macros, and I know precious little about excel..

Help...
 
I recorded a macro when I opened a .csv file. I changed the zoom to 75% and
changed the orientation to landscape.

I modified the recorded code to get this:

Option Explicit
Sub auto_open()
Workbooks.Open Filename:="C:\My Documents\excel\static.csv"
ActiveWindow.Zoom = 75
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\My Documents\excel\static.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = True
ActiveWorkbook.Close savechanges:=False
ThisWorkbook.Close savechanges:=False
End Sub

I can put this in a workbook that can be opened via a .bat file that contains:

start "c:\my documents\excel\book1.xls"

(modify the location in the .bat file and the auto_open code, too.)

I didn't have a guess how you would choose a random .csv file or why it would
have to be copied to the temp folder first.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Back
Top