I am working with some documents that have embedded tables. I need to merge
these documents but keep track of what information came from which document.
Only the 4th cell in each row (not including header rows) will be
copied/merged to a new document.
The preferred (existing) method is to add a UserID (each workbook creator's
initials, which is the same as the first two digits of the filename) to the
fourth cell in every row of the target tables (except the first row, which
is headers). Each document will have a number of tables. In addition to the
initials, I also need to add the content of the first cell in the same row,
since I will not be copying that over individually. For example:
Filename: MS_042706.doc
(any table, any row 2+)
col1 col2 col3 col4
Yes blah blah lots of text
++ blah blah lots of text
should end up as:
col1 col2 col3 col4
Yes blah blah lots of text (MSYes)
++ blah blah lots of text (MS++)
Here is my code, but it doesn't seem to like the way I refer to TempTable
(method or data member not found). Since I haven't got it working yet feel
free to comment on any other problems you see with the code if any jump out
at you...
Many thanks in advance,
Keith
Sub Add_Examiner_Info()
Dim TempTable As Table
Dim i As Integer
Dim CellValue
Dim RatingValue
UserId = InputBox("Enter Creator ID for active document", "Enter ID")
If Len(UserId) > 0 Then
With ActiveDocument
For Each TempTable In .Tables
With TempTable
If TempTable.Rows.Count > 2 Then
For i = 2 To TempTable.Rows.Count
CellValue = Trim(.TempTable.Rows(i).Cells(4).Text) '<<
stops here
RatingValue = Trim(.TempTable.Rows(i).Cells(4).Text)
.TempTable.Rows(i).Cells(4).Text = CellValue & _
" (" & UserId & RatingValue & ")"
Next i
End If
End With
Next
End With
Else
MsgBox "UserID cannot be blank" & Chr(13) & Chr(13) & "Please try
again", , "No ID entered"
End If
End Sub

Signature
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.
KR - 14 Aug 2006 21:41 GMT
OP here, but someone suggested to me that my original email alias is too
common and is likely to already be in different folk's kill files due to
other people who might have used the same alias.
If anyone has suggestions on the original problem below, I'd welcome any
help. I usually program in XL2003, so I'm a newbie to the Word object model.
Currently using Word2003, although once I get this working I'd like to share
it with other folks who might be using as far back as Word97.
Thanks,
Keith
> I am working with some documents that have embedded tables. I need to merge
> these documents but keep track of what information came from which document.
[quoted text clipped - 65 lines]
>
> End Sub
KR - 15 Aug 2006 13:17 GMT
OP, closing this thread. After several hours of trial and error last night,
I finally got it working.
CellValue = Trim(.TempTable.Rows(i).Cells(4).Text)
should have been
CellValue = Trim(TempTable.Rows(i).Cells(4).Range.Text)
(removed period before the table reference, and added the range qualifier)
> OP here, but someone suggested to me that my original email alias is too
> common and is likely to already be in different folk's kill files due to
[quoted text clipped - 89 lines]
> > thoughts, views, or policy of my employer. Any errors or omissions are my
> > own.