VBA excel paste to word deleting itself

S

Skyron

Hey guys

I've tried pasting cells to word both using

wrddoc.content.paste

and

wrddoc.content.pasteexceltable false false false

and I'm doing something wrong after that because I can't seem to inser
a page break, text or anything after that without delete the data.

I'd appreciate some help!


Ok, that wasn't exactly descrictive, sorry guys.

I'm trying to cut and paste some cells from excel to word, insert
page break and repeat the process on a new page.

Does anyone know how to get this done?

Thanks!!!

(Nigel, kkknei, Bob, and Juan, thanks for your help earlier
 
E

Ed

Hi, Skyron. You didn't post any code, but from your description and my
experiences (as a head-scratcher trying to figure out what I'm doing!), it
sounds like you're not moving the Selection off what you have just pasted
into Word. If it's still selected in Word, then the next thing you try to
insert or paste will replace your selection. Without seeing the code, it's
hard to recommend anything, but off the top of my head I'd suggest a
Selection.Collapse wdCollapseEnd, which will collapse the selection in Word
(note the "wd") to the end.

HTH
Ed
 
T

Tom Ogilvy

Help on word syntax/objects would probably be best asked in a word newgroup.

An alternative is to go to word and turn on the macro recorder while you
take the action manually.
 
S

Skyron

I tried the line of code you suggested.
Selection.Collapse wdCollapseEnd

Gave me an error that the "Object doesn't support this property o
method"

Then tried both
wrdApp.Selection.Collapse wdCollapseEnd
Word.selection.Collapse wdCollapseEnd
and still just overwriting the last paste when I go back through

Here's the code I'm trying to get to work.

Any help will be appreciated with beer if I can :)

With wrdDoc
'Write Data
Sheets("Sheet2").Select

For iWrd = 0 To Finali - 1
iFirstRow = iWrd * 28
iLastRow = (iWrd * 28) + 27
If iFirstRow = 0 Then
iFirstRow = 1
End If
Range("A" & iFirstRow & ":B" & iLastRow).Select
Selection.Copy

.Content.PasteExcelTable False, False, False
.Content.InsertBreak

Next iWr
 
Top