I have created this macro and it fails in Word. It will not run and complains about the xlToRight in the insert command and then all the sort functions it complains about too, i.e Range, xlAscending, etc. Yet it works in Excel. Is there some limit to calls made to Excel from other applications via VBA? Whats the fix?
Set xlApp = CreateObject("Excel.Application"
xlApp.Visible = True
xlApp.Workbooks.Add
'xlApp.ActiveSheet.Cells(1, 1).Value = mstrComponentPathNameList
thetest = DxTokenize(mstrComponentPathNameList, Chr(13), DXT_TABS_OK, ListArry())
For i = 1 To UBound(ListArry)
xlApp.ActiveSheet.Cells(i, 1).Value = ListArry(i)
Next i
With xlApp
.Cells.Select
.Selection.ColumnWidth = 77.86
.Selection.RowHeight = 14.25
.Columns("A:A"
.Select
.Selection.Insert Shift:=xlToRight
.Selection.Sort Key1:=Range("B1"
, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
.Rows("1:1"
.Select
.Selection.Delete
End With
Set xlApp = CreateObject("Excel.Application"
xlApp.Visible = True
xlApp.Workbooks.Add
'xlApp.ActiveSheet.Cells(1, 1).Value = mstrComponentPathNameList
thetest = DxTokenize(mstrComponentPathNameList, Chr(13), DXT_TABS_OK, ListArry())
For i = 1 To UBound(ListArry)
xlApp.ActiveSheet.Cells(i, 1).Value = ListArry(i)
Next i
With xlApp
.Cells.Select
.Selection.ColumnWidth = 77.86
.Selection.RowHeight = 14.25
.Columns("A:A"
.Selection.Insert Shift:=xlToRight
.Selection.Sort Key1:=Range("B1"
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
.Rows("1:1"
.Selection.Delete
End With