View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
robin robin is offline
external usenet poster
 
Posts: 210
Default copy from excel to word

Hi. I am trying to copy multiple cells from excel to word. I can do this
once with the following code, but on the second iteration, I get a 'command
error' at the pastespecial stage. I think its because I am not activating
Excel properly at the end of the first iteration, but I can't crack this.
Any help would be appreciated!

Sub ExcelDataToWorddoc()

Dim WordApp As Word.Application
Dim WordDoc As Word.Document

For i = 1 To 5
Set WordApp = GetObject(, "Word.Application")
WordApp.Visible = True
Set WordDoc = WordApp.ActiveDocument
ThisWorkbook.Sheets("from_Forms").Range("Strengths _Start").Offset(i - 1,
0).Copy
WordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
Application.CutCopyMode = False
Set WordDoc = Nothing
Set WordApp = Nothing
Sheets("from_Forms").Activate
Next i
End Sub