Any way to copy two paragraphs from one cell to multiple cells?

K

Kelly

I have built a table in Word 2003. The table has seven columns and many
rows. I wish to copy the contents of one cell to almost all the cells in a
column. The contents of the one cell has two paragraphs. I select the one
cell and click the copy button the toolbar. I then select all the cells
where I wish to paste the contents of the original cell. I click the paste
button on the toolbar. The results are odd. The first paragaph is pasted to
the first, third, fifth cell and so on. Every other cell receives the first
paragraph from the original cell starting with the first cell I selected to
receive the pasting. The second paragraph is pasted to the second, fourth,
sixth cell and so on. Every other cell receives the second paragraph from
the original cell starting with the second cell I select to receive the
pasting. I've tried everything I can think to do.

Is there an easy way to copy two paragraphs from one cell to multiple cells
with each cell receiving the contents of the original cell and not parsing
the contents of the orignail cell to many cells?

I appreciate any help you can provide.
 
S

Suzanne S. Barnhill

Bizarre! I would suggest this workaround. Replace the paragraph break in the
copied cell with, say, @@. Copy and paste, then use Find and Replace to
replace @@ with ^p in that column.
 
D

Doug Robbins - Word MVP

If you select the whole cell and copy it, then paste to a range of cells,
everything will be pasted into those cells.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
T

Tony Jollans

Interesting. Word doesn't normally paste to multiple places at the same time
like Excel does. It seems to be trying to help but I don't know what it's
doing - with a single paragraph it seems to paste the first sentence oer and
over. I found that if I copied the whole cell rather than the text within
it, it worked as you want.
 
G

Greg Maxey

If you really need just part of one cell pasted to multiple other selected
cells, then you will have to use a macro something like this:

Sub CopyPartOfOneCelltoSelectedCells()
Dim MyData As DataObject
Dim strClip As String
Dim oCell As Cell
Set MyData = New DataObject
MyData.GetFromClipboard
strClip = MyData.GetText
For Each oCell In Selection.Cells
oCell.Range.Text = strClip
Next
End Sub

See:
http://word.mvps.org/faqs/macrosvba/ManipulateClipboard.htm
 
D

Doug Robbins - Word MVP

Sure is bizarre! When I select and copy just the text of a cell containing
two paragraphs (not the whole cell), and then paste into multiple cells, in
each of the alternative cells is get just the first word of the alternate
paragraphs, not even the complete paragraph.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Greg Maxey

After further study, this might be better:

Sub CopyPartOfOneCelltoSelectedCells()
Dim MyData As DataObject
Dim oCell As Cell
Dim myString$
Set MyData = New DataObject
MyData.GetFromClipboard
myString = MyData.GetText
For Each oCell In Selection.Cells
If Asc(Right(myString, 2)) = 13 And Asc(Right(myString, 1)) = 10 Then
oCell.Range.Text = Left(MyData.GetText, Len(MyData.GetText) - 2)
Else
oCell.Range.Text = MyData.GetText
End If
Next
End Sub
 
G

Greg Maxey

Doug,

Seems to me that the weirdness starts in the selection.copy process.

Anytime you include a paragraph mark Chr(13) in the middle of a selection,
the clipboard automatically creates a Chr(10) after that Chr(13) and appends
a Chr(13) and Chr(10) to the end of the string.

You can observe this with the following:

Sub Demo()
Dim MyData As DataObject
Dim myString$, ASCString$
Dim oCharNum&, i&
Set MyData = New DataObject
MyData.GetFromClipboard
myString = MyData.GetText
For i = 1 To Len(myString)
ASCString = ASCString & Asc(Mid(myString, i, 1)) & "|"
Next i
ASCString = Left(ASCString, Len(ASCString) - 1)
MsgBox ASCString

I typed

Test
Test
Test

In a cell and selected the middle word and ran that code. I expected
81|101|115|116|13. I got 81|101|115|116
Next, I selected the first two words "without" the paragraph mark following
the second word and ran that code.
I expected 81|101|115|116|13|81|101|115|116 what I got was
81|101|115|116|13|10|81|101|115|116|13|10
For some reason the clipboard changing the text. I assume that this may
have some effect on how the text is then pasted, but I haven't figured out
the relationship.
 
T

Tony Jollans

I think this is normal copy behaviour. When you copy to the clipboard,
several different formats are put on the clipboard - reflected in the
various Paste Special options.

What is peculiar is the paste - as far as I know, multiple table cells is
the only instance of paste being targeted at multiple containers - in cases
of other multi-selections, paste is not available - Word seems to be trying
(and failing) to do something akin to what Excel does in similar
circumstances. It all works well when the copy source is one or more cells,
the attempted conversion just fails when the source is something else.
 
G

Greg

Tony,

It also seems to be version dependent. The results I reported
yesterday was from Word2003. Same test today in Word2000 the results
are totally different.

In 2000 the Chr(13) are not picked up even when present and the Chr(10)
is not appended.

Selecting the first word "Test" and the second word "Test" without the
paragraph mark returns:

84|101|115|116|84|101|115|116

So if I select "Test" Paragraph Mark "Test" the resultant .GetText
string is "TestTest." I wonder how Word then determines where to put
the paragraph mark back in that string when it performs a paste.

Obviously I am in an area over my head here.
 
T

Tony Jollans

It's no fun in the shallow end :)

If you look at the Edit > Paste Special choices you will see that HTML is
the default (which I presume is what you get from Paste) but you are looking
at the Text from your DataObject. However, the Paste As Unformatted gives
different behaviour in 2000 and 2003. Getting way out of my depth too (I
suspect Graham Mayor may know something of this if he's watching) but I
think there have been changes in conversions to and from text formats
between releases.

An interesting side note - copying a couple of small paragraphs in 2000 (on
ME) gave me 45K of clipboard data. Roughly the same in 2003 (on XP) gave me
about 4.5K.

Have to go out for most of the rest of the day now but I will investigate
some more later.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top