When creating an Excel worksheet from Outlook, the form fails with the error "Expected Statement" on the oSheet.Selection.Sort line. If I make the selection visible, the correct range is selected. Here is the code. Any idea what is causing this?
Set oExcel = Item.Application.CreateObject _
("Excel.Application"
oExcel.Workbooks.Add
Set oSheet = oExcel.Workbooks(1).Worksheets("Sheet1"
' Export data code goes here to fill i rows, 6 cols.
Set varRange = oSheet.Range(oExcel.Cells(6, 1), _
oExcel.Cells(i, 6))
varRange.Select
oSheet.Selection.Sort Key1:=Range("A6", _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Randy Carr
randy.carr@carteretcraven.ncemcs.com
Set oExcel = Item.Application.CreateObject _
("Excel.Application"
oExcel.Workbooks.Add
Set oSheet = oExcel.Workbooks(1).Worksheets("Sheet1"
' Export data code goes here to fill i rows, 6 cols.
Set varRange = oSheet.Range(oExcel.Cells(6, 1), _
oExcel.Cells(i, 6))
varRange.Select
oSheet.Selection.Sort Key1:=Range("A6", _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Randy Carr
randy.carr@carteretcraven.ncemcs.com