@Curtis_Waguespack maybe you can assist here?
i have gotten the code work in VBA , but i can't get the sort property to work in ilogic. i've tried about all the combinations i can think of. i know some functions are not available in vb.net, or use a different syntax. Any help would be appreciated or a simple its not possible would also make my head stop spinning. thank you in advance
here is the VBA code:
Sub SortExcelRange()
'set ref to workbook
Dim oWorkbook As Workbook
Set oWorkbook = GetObject("C:\Work\Designs\R and D\8551-8599\8585\AutodeskBlog\SortExcelRow.xlsx")
'set ref to active sheet
Dim oActiveSheet As WorkSheet
Set oActiveSheet = oWorkbook.Sheets.Item(1)
'sort the rows. column b is primaary column in this example.
Call oActiveSheet.Range("a2:c12").Sort(oActiveSheet.Range("b2"), xlAscending)
End Sub
here is the ilogic (vb.net), i can't get the sort fields to take the inputs.
Imports Microsoft.Office.Interop 'To use excel
Imports ExcelApp = Microsoft.Office.Interop.Excel 'To use excel
AddReference "Microsoft.Office.Interop.Excel" 'To use excel
AddReference "microsoft.office.interop.excel.dll"
'set ref to workbook
Dim oExcelApp As ExcelApp.Application = CreateObject("Excel.application")
Dim oExcelWorkbook As Excelapp.Workbook = oExcelApp.Workbooks.Open("C:\Work\Designs\R and D\8551-8599\8585\AutodeskBlog\SortExcelRow.xlsx")
'set ref to active sheet
Dim oActiveSheet As Excelapp.Worksheet = oExcelWorkbook.Sheets("Sheet1")
'sort the rows. column b is primaary column in this example.
Dim oRangeSort As Excel.Range = oActiveSheet.Range("A2:C12")
Dim oRangeSortColumn As Excel.Range = oActiveSheet.Range("b2:b12")
oExcelApp.ActiveWorkbook.Worksheets("Sheet1").Sort.sortfields.add2(oRangeSortColumn, xlSortOnValues, xlDescending, , xlSortNormal, )