ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dropping Data When Copying (https://www.excelbanter.com/excel-programming/410827-dropping-data-when-copying.html)

Anne[_6_]

Dropping Data When Copying
 
In the code below, I am copying data from an Excel worksheet to a Word
doc. It works great, except only the first 1024 characters in a cell
are getting copied. The rest is getting dropped. I have verified the
data (over 1024) is in the Excel cell when it is copied. I can't
figure why this is happening. I know some eariler versions of Excel
had display limitations. I am using Excel 2002 and 2003. I have also
tried formatting the worksheet before it is copied to make sure all
data is visible in the cell before it's copied and it still drops char
over 1024. Any ideas would be greatly appreciated.

Anne

-----------------
Sub PasteDataTest()
'go to the worksheet and get copy the data to the word file
Worksheets("Temp").Activate
Range("A1").Select
ActiveCell.CurrentRegion.Select
Selection.Name = "myRange"

' copy the range, assumes current excel active workbook
Range("myRange").Copy

' Paste as formatted text.
WordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteRTF,
_
Placement:=wdInLine, DisplayAsIcon:=False

End Sub

joel

Dropping Data When Copying
 
I think the problem is with the RTF option. I manualy copied 2000 character
from excel and the in a word document used paste special with the RTF format
and the data was truncated. If I used other formats the data wasn't
truncated.

"Anne" wrote:

In the code below, I am copying data from an Excel worksheet to a Word
doc. It works great, except only the first 1024 characters in a cell
are getting copied. The rest is getting dropped. I have verified the
data (over 1024) is in the Excel cell when it is copied. I can't
figure why this is happening. I know some eariler versions of Excel
had display limitations. I am using Excel 2002 and 2003. I have also
tried formatting the worksheet before it is copied to make sure all
data is visible in the cell before it's copied and it still drops char
over 1024. Any ideas would be greatly appreciated.

Anne

-----------------
Sub PasteDataTest()
'go to the worksheet and get copy the data to the word file
Worksheets("Temp").Activate
Range("A1").Select
ActiveCell.CurrentRegion.Select
Selection.Name = "myRange"

' copy the range, assumes current excel active workbook
Range("myRange").Copy

' Paste as formatted text.
WordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteRTF,
_
Placement:=wdInLine, DisplayAsIcon:=False

End Sub


Anne[_6_]

Dropping Data When Copying
 
On May 13, 2:51*am, Joel wrote:
I think the problem is with the RTF option. *I manualy copied 2000 character
from excel and the in a word document used paste special with the RTF format
and the data was truncated. *If I used other formats the data wasn't
truncated.



"Anne" wrote:
In the code below, I am copying data from an Excel worksheet to a Word
doc. *It works great, except only the first 1024 characters in a cell
are getting copied. *The rest is getting dropped. *I have verified the
data (over 1024) is in the Excel cell when it is copied. *I can't
figure why this is happening. *I know some eariler versions of Excel
had display limitations. *I am using Excel 2002 and 2003. *I have also
tried formatting the worksheet before it is copied to make sure all
data is visible in the cell before it's copied and it still drops char
over 1024. *Any ideas would be greatly appreciated.


Anne


-----------------
Sub PasteDataTest()
*'go to the worksheet and get copy the data to the word file
* * Worksheets("Temp").Activate
* * Range("A1").Select
* * ActiveCell.CurrentRegion.Select
* * Selection.Name = "myRange"


* * ' copy the range, assumes current excel active workbook
* * Range("myRange").Copy


* * ' Paste as formatted text.
* * WordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteRTF,
_
* * Placement:=wdInLine, DisplayAsIcon:=False


End Sub- Hide quoted text -


- Show quoted text -


Thanks for the reply Joel. I ended up using the following code and
the data is no longer truncated, but the formatting is now less
predicatable. I will have to make sure my users don't have long
continuous lines of text in the cell. If they format the cell text
width with <alt<enter the width size stays ok during the copy. I
couldn't find any of keeping the formatting with the paste without
truncating.

Another option I tried was copying the data as
DataType:=wdPasteOLEObject, but that didn't work either. I checked
MS website to see if this is a known bug or if there are any patches,
but couldn't find any information.

Sub PasteDataPlain()

'go to the worksheet and get copy the data to the word file

Worksheets("Temp").Activate
Range("A1").Select
ActiveCell.CurrentRegion.Select
Selection.Name = "myRange"

' copy the range, assumes current excel active workbook

Range("myRange").Copy

'Copies Excel table to Word without RTF to prevent data getting
cut off after 1024 characters
WordApp.Selection.PasteExcelTable False, False, False


End Sub


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com