View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.programming,microsoft.public.word.vba.general
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Automating Excel from Word - How to Sort a Range of Cells

' tSheet.Sort.SortFields. _
' Add Key:=Range("A11"), SortOn:=xlSortOnValues, Order:=xlAscending,
_
' DataOption:=xlSortNormal
' With tSheet.Sort
' .SetRange Range("A11:T" & j - 1)

When automating Excel you need to fully qualify objects. In the above those
Range objects are not.
Probably you want tSheet.Range(etc

Don't forget "Range" is both Excel and Word, also need to qualify in
declarations.

Looks like you are using early binding but if not don't use named constants
like xlSortNormal, or declare them yourself. This is in passing, I don't
think an issue with yours.

There may well be other errors but that's what I spotted with a quick skim
through.

There's rarely a need to Select or Activate in Excel, and rarer still to
need SendKeys.

Regards,
Peter T