View Single Post
 
Old 03-14-2022, 04:53 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It is probably best to error trap each table to ensure that you are processing the correct tables e.g. as follows. I have assumed each table has six cells - change each as appropriate. However why do you need to change the tables? Wouldn't it be better to create your document from a template that already has the masthead correctly formatted?

Code:
Dim oTable As Table
Dim i As Integer
    If ActiveDocument.Tables.Count > 3 Then
        If ActiveDocument.Tables(1).Range.Cells.Count = 6 And _
           ActiveDocument.Tables(2).Range.Cells.Count = 6 And _
           ActiveDocument.Tables(3).Range.Cells.Count = 6 And _
           ActiveDocument.Tables(4).Range.Cells.Count = 6 And _
           ActiveDocument.Tables(4).Range.Information(wdActiveEndPageNumber) = 1 Then
            For i = 1 To 4
                Set oTable = ActiveDocument.Tables(i)
                'Do something with otable e.g.
                oTable.Cell(1, 1).Range.Text = "Test"
            Next i
        End If
    End If
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote