![]() |
|
#1
|
|||
|
|||
|
Hi all! This is my first project in Word, as you can see I'm a bit inexperienced ![]() I'm comparing the content in two documents, and replacing/updating the content in Userdocument's tables. If the table have one row, it inserts a new column instead of updating the content. My question:
Code:
'/ UpdateContent in leftmost column
Private Sub CompareAddContent( _
MalCol As Column, _
UserCol As Column _
)
Dim Cell As Cell
Dim row As Integer
Dim cl_Match As Cell
Dim NewRow As row
For Each Cell In MalCol.Cells
Cell.Range.Copy
Set cl_Match = LookForMatch(UserCol, Cell.Range.Text) ' This function looks for correct content (Works)
If cl_Match Is Nothing Then
'/ Insert new row and add content
Set NewRow = UserCol.Parent.Rows.Add
NewRow.Cells(1).Range.PasteAndFormat wdFormatOriginalFormatting
Else
'/ Replace content in cell
'/ ***********************
'/ It works fine if the number of rows > 1
cl_Match.Range.PasteAndFormat wdFormatOriginalFormatting
'/ **********************
End If
Next
End Sub
|
| Tags |
| tables, vba macro |
| Thread Tools | |
| Display Modes | |
|
|
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 |