Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cut and Paste gets overwritten, WHY? :)

Hey Guys,
I've been trying to use VBA in Excel to cut and paste to Word a set o
cells.
I'm trying to use a loop to cut and paste multiple times on differen
pages.

The problem lies in that everytime I paste it overwrites the previou
paste I made. I've tried recording a macro in Word to see wha
happens, and everything doesn't work the same way when using excel'
macro.

It appears that when I make a paste I've still got the previous past
selected and it overwrites.

Here's a set of code I've been trying to get to work, I REALL
appreciate if someone could help me out! I'm desperate and bee
banging my head against the wall with this. HELP!! :p

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.InsertAfter "Header"
.Content.PasteExcelTable False, False, False

.Content.InsertBreak

Next iWr

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Cut and Paste gets overwritten, WHY? :)

Skyron,

The overwriting is probably due to what is currently selected in Word: you
previous paste.

Try using the collapse method:

Selection.Collapse Direction:=wdCollapseEnd
Selction.MoveEnd Unit:=wdCharacter, Count:=-1

Beyond that, you would need to take this question to the Word groups.

HTH,
Bernie
MS Excel MVP

"Skyron " wrote in message
...
Hey Guys,
I've been trying to use VBA in Excel to cut and paste to Word a set of
cells.
I'm trying to use a loop to cut and paste multiple times on different
pages.

The problem lies in that everytime I paste it overwrites the previous
paste I made. I've tried recording a macro in Word to see what
happens, and everything doesn't work the same way when using excel's
macro.

It appears that when I make a paste I've still got the previous paste
selected and it overwrites.

Here's a set of code I've been trying to get to work, I REALLY
appreciate if someone could help me out! I'm desperate and been
banging my head against the wall with this. HELP!! :p

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.InsertAfter "Header"
Content.PasteExcelTable False, False, False

Content.InsertBreak

Next iWrd


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
overwritten files roseprince Excel Discussion (Misc queries) 1 October 6th 09 04:23 PM
Overwritten Equations dbsocal Excel Discussion (Misc queries) 5 March 4th 09 10:06 PM
Overwritten Fil quad Excel Discussion (Misc queries) 3 November 14th 08 07:32 PM
overwritten file jap786 Charts and Charting in Excel 1 July 3rd 06 04:00 PM
.XLB OverWritten Alex J Excel Discussion (Misc queries) 1 December 18th 04 10:45 PM


All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"