Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-11-2014, 05:32 PM
macropod's Avatar
macropod macropod is online now Copy table content between documents Windows 7 32bit Copy table content between documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,520
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try the following macro. Add it to your destination document (or to Word's 'Normal' template and activate your destination document), then run it. Select the source document and the destination document will be updated.

Note: I had to change your source row references, plus some destination column references, and you seemed to have too many cells overall. I've also managed to exclude the source table headings.


Code:
Sub XferTblData()
Application.ScreenUpdating = False
Dim DocSrc As Document, TblSrc As Table, RngSrc As Range, RowSrc As String, ColSrc As String
Dim DocTgt As Document, TblTgt As Table, RngTgt As Range, RowTgt As String, ColTgt As String
Dim i As Long
RowSrc = "5,5,6,6,7,7,9,9,11,11"
ColSrc = "1,2,1,2,1,2,1,2,1,2"
RowTgt = "10,10,12,12,14,14,17,17,20,20"
ColTgt = "1,2,1,2,1,2,1,2,2,3"
Set DocTgt = ActiveDocument
With Application.Dialogs(wdDialogFileOpen)
  If .Show = -1 Then
    .AddToMru = False
    .ReadOnly = True
    .Visible = False
    .Update
    Set DocSrc = ActiveDocument
  End If
End With
If DocSrc Is Nothing Then Exit Sub
Set TblSrc = DocSrc.Tables(2)
Set TblTgt = DocTgt.Tables(1)
For i = 0 To UBound(Split(RowSrc, ","))
  Set RngSrc = TblSrc.Cell(Split(RowSrc, ",")(i), Split(ColSrc, ",")(i)).Range
  RngSrc.End = RngSrc.End - 1
  RngSrc.Start = RngSrc.Paragraphs(1).Range.End
  Set RngTgt = TblTgt.Cell(Split(RowTgt, ",")(i), Split(ColTgt, ",")(i)).Range
  RngTgt.End = RngTgt.End - 1
  RngTgt.FormattedText = RngSrc.FormattedText
Next
DocSrc.Close SaveChanges:=False
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 06-11-2014, 09:12 PM
mcb09 mcb09 is offline Copy table content between documents Windows 7 32bit Copy table content between documents Office 2010 32bit
Novice
Copy table content between documents
 
Join Date: Jun 2014
Posts: 8
mcb09 is on a distinguished road
Default

This is AMAZING, Paul! Thank you! I do get the below message. I click and END and it completes the macro. Row 10, Col 2 of the target doc doesn't get populated with content (Row 20, Col 2 of the source).
Attached Images
File Type: png Capture.PNG (19.5 KB, 48 views)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy content control entries to next table next page Mel_Herndon Word VBA 2 05-22-2014 05:07 PM
Copy table content between documents Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM
Copy table content between documents Content of all documents in folder changes to match one of them jemmac2525 Word 2 11-11-2013 12:32 AM
table of content suna Word 2 05-16-2013 02:39 PM
Copy table content between documents share content between documents? albytrott Word 1 10-08-2009 08:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft