A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Copying markups from one table to another



 
 
Thread Tools Display Modes
  #1  
Old November 30th 05, 07:59 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default Copying markups from one table to another

I have a document that has one table containing markups. I need to copy the
cell contents (including markups) into another table. How do I do it? The
methods for copying markups in non-table text do not seem to work. Any help
is appreciated.
Ads
  #2  
Old December 6th 05, 10:28 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default Copying markups from one table to another

Hi Chilly,

Nothing built-in allows you to copy and paste table cells including their
formatting, AFAIK.

You can try the macros below.

"CopyTableCells" just puts a bookmark "oldCells" on selected cells.
"PasteTableCells" then pastes the cells from that bookmark into the selected
cells, and formats them.

The macro isn't exceedingly clever, and doesn't try to catch errors (say if
you aren't in a table when running them, or when you selected more or less
cells when pasting than when "copying".)

If you haven't used macros before, see
http://www.word.mvps.org/FAQs/Macros...eateAMacro.htm

Regards,
Klaus


Sub CopyTableCells()
ActiveDocument.Bookmarks.Add _
Range:=Selection.Range, _
Name:="oldCells"
End Sub

Sub PasteTableCells()
Dim myCell As Cell
Dim oldCell As Cell
Dim myShading As Shading
Dim i As Long
ActiveDocument.Bookmarks.Add _
Range:=Selection.Range, _
Name:="newCells"
' Copy/paste over the contents
ActiveDocument.Bookmarks("oldCells").Select
Selection.Copy
ActiveDocument.Bookmarks("newCells").Select
Selection.Paste

' Format the cells like those in bookmark "oldCells":
With ActiveDocument.Bookmarks("oldCells").Range.Cells
For i = 1 To Selection.Cells.Count
ActiveDocument.Bookmarks("oldCells").Select
If Selection.Cells.Count = i Then
Set oldCell = Selection.Cells(i)
Else
Set oldCell = Selection.Cells(1)
End If
ActiveDocument.Bookmarks("newCells").Select
Set myCell = Selection.Cells(i)
With myCell
With .Shading
.BackgroundPatternColorIndex = _
oldCell.Shading.BackgroundPatternColorIndex
.BackgroundPatternColor = _
oldCell.Shading.BackgroundPatternColor
.ForegroundPatternColorIndex = _
oldCell.Shading.ForegroundPatternColorIndex
.ForegroundPatternColor = _
oldCell.Shading.ForegroundPatternColor
.Texture = oldCell.Shading.Texture
End With
.Borders = oldCell.Borders
.LeftPadding = oldCell.LeftPadding
.RightPadding = oldCell.RightPadding
.TopPadding = oldCell.TopPadding
.BottomPadding = oldCell.BottomPadding
.HeightRule = oldCell.HeightRule
If oldCell.Height wdUndefined Then
.Height = oldCell.Height
End If
.Column.PreferredWidthType = _
oldCell.PreferredWidthType
.Column.PreferredWidth = _
oldCell.PreferredWidth
.Column.Width = oldCell.Width
End With
Next i
End With
ActiveDocument.Bookmarks("newCells").Select
End Sub







"Chilly" wrote:
I have a document that has one table containing markups.
I need to copy the cell contents (including markups) into
another table. How do I do it? The methods for copying
markups in non-table text do not seem to work. Any help
is appreciated.



  #3  
Old December 6th 05, 11:30 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default Copying markups from one table to another

Thanks. I'll give it a try.

"Klaus Linke" wrote:

Hi Chilly,

Nothing built-in allows you to copy and paste table cells including their
formatting, AFAIK.

You can try the macros below.

"CopyTableCells" just puts a bookmark "oldCells" on selected cells.
"PasteTableCells" then pastes the cells from that bookmark into the selected
cells, and formats them.

The macro isn't exceedingly clever, and doesn't try to catch errors (say if
you aren't in a table when running them, or when you selected more or less
cells when pasting than when "copying".)

If you haven't used macros before, see
http://www.word.mvps.org/FAQs/Macros...eateAMacro.htm

Regards,
Klaus


Sub CopyTableCells()
ActiveDocument.Bookmarks.Add _
Range:=Selection.Range, _
Name:="oldCells"
End Sub

Sub PasteTableCells()
Dim myCell As Cell
Dim oldCell As Cell
Dim myShading As Shading
Dim i As Long
ActiveDocument.Bookmarks.Add _
Range:=Selection.Range, _
Name:="newCells"
' Copy/paste over the contents
ActiveDocument.Bookmarks("oldCells").Select
Selection.Copy
ActiveDocument.Bookmarks("newCells").Select
Selection.Paste

' Format the cells like those in bookmark "oldCells":
With ActiveDocument.Bookmarks("oldCells").Range.Cells
For i = 1 To Selection.Cells.Count
ActiveDocument.Bookmarks("oldCells").Select
If Selection.Cells.Count = i Then
Set oldCell = Selection.Cells(i)
Else
Set oldCell = Selection.Cells(1)
End If
ActiveDocument.Bookmarks("newCells").Select
Set myCell = Selection.Cells(i)
With myCell
With .Shading
.BackgroundPatternColorIndex = _
oldCell.Shading.BackgroundPatternColorIndex
.BackgroundPatternColor = _
oldCell.Shading.BackgroundPatternColor
.ForegroundPatternColorIndex = _
oldCell.Shading.ForegroundPatternColorIndex
.ForegroundPatternColor = _
oldCell.Shading.ForegroundPatternColor
.Texture = oldCell.Shading.Texture
End With
.Borders = oldCell.Borders
.LeftPadding = oldCell.LeftPadding
.RightPadding = oldCell.RightPadding
.TopPadding = oldCell.TopPadding
.BottomPadding = oldCell.BottomPadding
.HeightRule = oldCell.HeightRule
If oldCell.Height wdUndefined Then
.Height = oldCell.Height
End If
.Column.PreferredWidthType = _
oldCell.PreferredWidthType
.Column.PreferredWidth = _
oldCell.PreferredWidth
.Column.Width = oldCell.Width
End With
Next i
End With
ActiveDocument.Bookmarks("newCells").Select
End Sub







"Chilly" wrote:
I have a document that has one table containing markups.
I need to copy the cell contents (including markups) into
another table. How do I do it? The methods for copying
markups in non-table text do not seem to work. Any help
is appreciated.




  #4  
Old July 24th 16, 03:42 PM
YossiD YossiD is offline
Junior Member
 
First recorded activity by WordBanter: Jul 2016
Posts: 1
Default

Looks like I'm a bit late to this party, but AFAIK, this is still a problem in Word (I've only tried up to Word 2007).

I have not tried the macros mentioned in an earlier reply, but I did manage with a different workaround.

1. Convert the table to text
2. Copy-paste with markups
3. Convert text to table

There are two problems with this method:
a. The new table is unformatted, so the formatting has to be reapplied
b. Tabs and paragraph marks that are part of the changed test will be ignored, which will wreck the table structure. These need to be replaced with "clean" tabs and paragraph marks before reconverting to a table.

It's a messy business, but it does work.

Has anyone tried the macros? How well do they work?






Quote:
Originally Posted by Chilly View Post
I have a document that has one table containing markups. I need to copy the
cell contents (including markups) into another table. How do I do it? The
methods for copying markups in non-table text do not seem to work. Any help
is appreciated.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
table column size changes when copying and pasting goingyourway Tables 2 December 5th 05 02:09 AM
Table headers/footers and layout Keith Page Layout 1 April 8th 05 07:37 PM
How to Avoid Word 2003 Table Style Problems Judy Haynes Tables 0 March 23rd 05 06:41 PM
Table AutoFormats vs. Table Styles confusion Tony Jollans Tables 5 March 6th 05 07:18 PM
Copying a Table Into a Table Karen Microsoft Word Help 1 January 14th 05 03:06 PM


All times are GMT +1. The time now is 02:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright 2004-2017 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.