Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim ObjXL As Excel.Application
Dim CmdArgs()
CmdArgs() = GetCommandLine 'Split the command line into 2 arguments the first is the
'excel file to convert, the second is the name to save the CSV file as. Store these 2
'filenames in the array CmdArgs
CSVDir = Mid(CmdArgs(2), 1, InStr(CmdArgs(2), "\"))
On Error Resume Next
Kill CmdArgs(2) 'if the CSV file already exists delete it so excel can save to that
'filename without prompting the user
Kill CSVDir & "convert"
On Error GoTo 0
Set ObjXL = CreateObject("excel.application") 'create a new instance of excel in
'memory to handle the conversion. this is completely seperate from any already running
'instances of excel, and the opening and conversion is done in the background.
ObjXL.Interactive = False ' This line tells excel to ignore user input. this is
'not really nessecary because we created an 'invisible' instance of excel, but it is
'always a good idea when controlling excel progromatically
ObjXL.DisplayAlerts = False 'This line tells excel not to ask whether to overwrite
'files, change from excel format to csv, etc..
ObjXL.Workbooks.Open FileName:=CmdArgs(1) 'Open the file that is specified in the first
'command line argument
ObjXL.ActiveWorkbook.Saved = True ' "trick" excel into thinking the original excel file
'has been saved. again not really necessary since excel will not be prompting for user
'input, but always a good idea if you have no changes to save to the excel file
ObjXL.ActiveSheet.SaveAs FileName:=CmdArgs(2), FileFormat:=xlCSV, CreateBackup:=False
'Saves the excel file as a CSV file with the name specified in the second argument
'the FileFormat:=xlCSV is the important part that does the conversion
ObjXL.Workbooks.Close 'Close the file
ObjXL.Quit 'Close the instance of excel in memory
ObjXL.Interactive = True 'Let Excel accept user input again
ObjXL.DisplayAlerts = True 'Let excel prompt before saving, closing, etc.
Set ObjXL = Nothing 'Release the refrence to excel, this allows the instance of excel
'to be cleared from memory