View Single Post
 
Old 12-19-2013, 04:00 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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:
Code:
Sub Insert_R_C_into_every_cell()
    Dim Rng As Range, aTable As Table, r As Long, c As Long, cellvalue As String
    For Each aTable In ActiveDocument.Tables
        With aTable
            ' insert each cell value into the master table
            For r = 1 To .Rows.Count
                For c = 1 To .Columns.Count
                    ' insert a cell ID into every cell
                    cellvalue = "Cell_ID[" & r & ", " & c & "]"
                    Set Rng = .Cell(r, c).Range
                    With Rng
                        .End = .End - 1
                        .Collapse wdCollapseEnd
                        .Text = cellvalue
                        .Font.Hidden = True
                    End With
                Next
            Next
        End With
    Next aTable
 End Sub
Aside from the application of the range variable, note the variable declarations and other simplifications.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote