View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.programming,microsoft.public.word.vba.general
Doug Robbins - Word MVP on news.microsoft.com Doug Robbins - Word MVP on news.microsoft.com is offline
external usenet poster
 
Posts: 10
Default Automating Excel from Word - How to Sort a Range of Cells

Thanks, Peter

Using tsheet.Range() is what was required.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Peter T" <peter_t@discussions wrote in message
...
' 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