Message 1 of 8
Sorting excel range through iLogic

Not applicable
07-10-2019
06:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
How can I sort a range in Excel through iLogic?
When I try the following code:
Sub Main() Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim oBOM As BOM = oDoc.ComponentDefinition.BOM Dim objExcel = CreateObject("Excel.Application") ThisBOM.Export("Parts Only", "C:\Users\ben.wouters\Desktop\TEST.xlsx", kMicrosoftExcelFormat) Dim objWorkbook = objExcel.Workbooks.Open("C:\Users\ben.wouters\Desktop\TEST.xlsx") excelSheet = objWorkbook.Worksheets(1) objExcel.Columns.AutoFit excelSheet.Range("A1:I16").Sort(Key1:=excelSheet.Range("C1"), Order1:=xlAscending, Header:=xlYes) objExcel.Application.Visible = True End Sub
I get an error message saying "Method Sort of class Range has failed".
However when I run the rule with the sort line commented out, it runs just fine. It just doesn't get sorted.
I'v tried a bunch of stuff, but either it throws up the error message above or I get the following: "Exception from HRESULT: 0x800A03EC".
Any help would be greatly appreciated.