--
Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog
dlg.Filter= "excel文件|*.xlsx" \'设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.filename)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.Columns("A:P")
Rg.sort(key1:=Ws.Range("G3"),header:= MSExcel.XlYesNoGuess.xlyes,Orientation:= MSExcel.XlSortOrientation.xlSortColumns)
wb.save
wb.close
End If