Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi again Robin,
Perhaps a little more info so that I can attempt to emulate exactly what you have. What version of Office (Word and Excel) are you using? What is the actual range of of the defined name "Strengths_Start"? I tested it in Office XP (2002) and it works fine with or without AppActivate. On reviewing my code, AppActivate is really only required once (if at all) because Excel is not being activated again during the code until after the Copy/Paste. I wonder if you need a line feed in Word after each paste. After the paste, the selection is actually at the end of the last line pasted so if you want each paste to be under the previous line then a line feed is required otherwise the paste commences at the end of the last line pasted. Sub ExcelDataToWorddoc() Dim WordApp As Word.Application Dim WordDoc As Word.Document Dim i As Long Set WordApp = GetObject(, "Word.Application") WordApp.Visible = True Set WordDoc = WordApp.ActiveDocument AppActivate ("Microsoft Word") For i = 1 To 5 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 WordApp.Selection.TypeParagraph 'Line feed in word Next i Set WordDoc = Nothing Set WordApp = Nothing AppActivate "Microsoft Excel" Sheets("from_Forms").Activate End Sub Both of the following work in Word 2002 AppActivate ("Microsoft Word") AppActivate ("Word") but only the following for Excel AppActivate ("Microsoft Excel") -- Regards, OssieMac |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy from Word to Excel | Excel Worksheet Functions | |||
copy excel to word | Excel Programming | |||
Macro to find a word and copy all rows with this word to diff ws | Excel Programming | |||
Copy from Word to Excel, and retain indent, plus word wrap | Excel Discussion (Misc queries) | |||
search for a specific word and copy the word and the preceeding words until a comma | Excel Programming |