![]() |
|
#3
|
|||
|
|||
|
I'll try to explain better, Sorry if I'm wasting to much of your time.
My question is: If a table has only 1 row, are there any problems/limitations with the Range.paste method I'm not aware of? Added a crude code below, hope it explains to some extent what I'm trying to achieve. Code:
'/ Copy tables from master document to userdoc
Sub CopyTables( _
)
Dim MasterDoc As Word.Document
Dim UserDoc As Word.Document
Dim MyTable As Word.Table
Dim rng_Paste As Variant
Dim MyCell As Word.Cell
Dim i As Integer
Set MasterDoc = Documents("MasterDoc.docx")
Set UserDoc = Documents("UserDoc.docm")
'/ Paste content from tables in MasterDoc to tables in UserDoc
For Each MyTable In MasterDoc.Tables
i = i + 1
For Each MyCell In MyTable.Columns(1).Cells
Set rng_Paste = UserDoc.Tables(i).Cell(MyCell.RowIndex, 1).Range
'/ If the number of rows = 1, it inserts a new column instead of replacing the
'/ content in rng_Paste. If number of rows > 1 it replaces the content of
'/ rng_Paste (As it should)
MyCell.Range.Copy
rng_Paste.Paste wdFormatOriginalFormatting
Next
Next
End Sub
Regarding the content; It's mainly text/hyperlinks, though it seems like the problems relates to the number of rows in a table, and not the content itself. It works just fine with any table if the number of rows is grater than As for the if/else, there's two possibilites (As I see them):
|
| Tags |
| tables, vba macro |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Loop and Update Content Controls with value | vss712 | Word VBA | 7 | 08-27-2015 08:56 PM |
| Update fields and Tables of Content with one macro | brent chadwick | Word VBA | 7 | 03-11-2015 07:21 AM |
Combine Different Word files into one file and update Table of Content
|
tejaspareek | Word VBA | 4 | 11-04-2014 05:50 AM |
How to align And center the content of the column in a table?
|
Jamal NUMAN | Word | 1 | 05-02-2011 05:47 PM |
SOS - cannot update table of content properly
|
Lee | Word | 5 | 02-04-2011 12:59 PM |