Take this example :
Const xlAscending = 1
Const xlYes = 1
Dim filePath
filePath = "C:\Users\book1.xlsx"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False
Dim objWorkbook
Set objWorkbook = _
objExcel.Workbooks.Open(filePath)
Set objWorksheet = objWorkbook.Worksheets(1)
Set objRange = objWorksheet.UsedRange
Set objRange2 = objExcel.Range("A1")
objRange.Sort objRange2, xlAscending, , , , , , xlYes
'objExcel.Application.DefaultSaveFormat = xlWorkbookNormal'
objWorkbook.Save
objExcel.Application.Quit
Set objExcel = Nothing
please conctrate on following :
objWorkbook.Save
objExcel.Application.Quit
Set objExcel = Nothing
objExcel.Visible = False
objExcel.DisplayAlerts = False
Visible = false means that excel will not open
DisplayAlerts = false allow you to ignore msgBox that pop up when you try to change excel .
the first 2 commands are to close excel file.
hope all clear , let me know if you have more questions