View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Stevens[_2_] Ed Stevens[_2_] is offline
external usenet poster
 
Posts: 4
Default Inserting selected range into Word document

Using examples previously found here and on MS website, I'm able to
get my macro to start Word , open a new document., and insert some
text into that document. Now I need to be able to insert a range of
selected cells. My first cut was this:

Sub createDoc()

Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Dim wordRng As Word.Range
Dim wordPara As Word.Paragraph

Set wordApp = CreateObject("Word.Application")
wordApp.Visible = True

With wordApp
.WindowState = wdWindowStateMaximize
.Documents.Add
Set wordDoc = wordApp.ActiveDocument
Set wordRng = wordDoc.Range

With wordRng

' this works
.InsertAfter "Running Word Using Automation"
' this doesn't
.InsertAfter range(cells(1,1),cells(lngLastRow,lngLastCol))
'nor does this
.InsertAfter
range(cells(1,1),cells(lngLastRow,lngLastCol)).sel ect
<snip rest of code



So, I need someone to get me back on track

Thanks in advance.