I'm a novice and I'm trying to run a sort on an Excel spreadsheet, but get an error:

Public Member 'Sort' on type 'workbook' not found

Here is the code. I'm using VB Express 2010. Any help would be appreciated!



Option Strict Off
Option Infer On
Imports Excel = Microsoft.Office.Interop.Excel
Imports Microsoft.Office
Imports System.Runtime.InteropServices
Imports System.Data
Imports System.Reflection


Module Module1
Public Interface Sort

End Interface


Public oExcel As New Microsoft.Office.Interop.Excel.Application
Public oBook As Microsoft.Office.Interop.Excel.Workbook
Public oSheet As Microsoft.Office.Interop.Excel.Worksheet


Sub Main()



oBook = oExcel.Workbooks.Open("D:\DVD List.xls") ' replace "yourfile" with your filepath & name

oSheet = CType(oBook.ActiveSheet, Excel.Worksheet)

oBook.Activate()



oBook.Sort( _
Key1:=oSheet.Columns(6), Order1:=Excel.XlSortOrder.xlAscending, _
Key2:=oSheet.Columns(1), Order2:=Excel.XlSortOrder.xlAscending, _
Orientation:=Excel.XlSortOrientation.xlSortColumns, _
Header:=Excel.XlYesNoGuess.xlNo, _
SortMethod:=Excel.XlSortMethod.xlPinYin, _
DataOption1:=Excel.XlSortDataOption.xlSortNormal, _
DataOption2:=Excel.XlSortDataOption.xlSortNormal, _
DataOption3:=Excel.XlSortDataOption.xlSortNormal)

oBook.SaveAs("D:\DVD List1.xls")

End Sub

End Module