I have written a Macro in WinWord2007 which lists styles and their properties in an Excel table. The table is made accessible by the following 3 lines:
Dim Oxl_Sheet As Object Set Oxl_Sheet = CreateObject("Excel.Sheet") Oxl_Sheet.Application.Visible = True
I can without problems write into individual cells of the table, for example:
Oxl_Sheet.Application.Cells(iRow, 2).Value = ActiveDocument.Styles.(iStyle).NameLocal
I would now like to sort the completed table from within the same Word macro, but I have found myself utterly unable to do so. In the following line, for example:
Oxl_Sheet.Application.Sort.SortFields.Add Key:=Range("I2:I356"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
the compiler complains that the Sub/Function "Range" has not been defined.
Can anybody give me a hint?