word  2013 VBA - Macro Needed to 1) Find Table, 2) select first row, 3) Change font size of first row to 16 pt and font to Arial Bold

brothertruffle880
brothertruffle880 used Ask the Experts™
on
Hi All:
I have 40 or so tables in a document which need to be modified.
I need a macro to
1) Find a Table,
2) select the first row in that table,
3) Change the font size of that table's first row to 16 pt and the font to Arial Bold
4) Repeat Step 1 2 and 3 until the end of the  document is reached.
5) Generate a message box saying "Done.".
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
Please give this a try...


Sub FormatTableRow()
Dim doc As Document
Dim tbl As Table

Set doc = ActiveDocument
For Each tbl In doc.Tables
    With tbl.Rows(1).Range.Font
        .Bold = True
        .Size = 16
        .Name = "Arial"
    End With
Next tbl
MsgBox "Done!", vbInformation
End Sub

Open in new window

Author

Commented:
Hi Neeraj:
The macro is fine but I would like to see each table as it is being processed.
Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
The macro is fine but I would like to see each table as it is being processed.
What do you mean by that? You cannot see the progress of the macro as it will complete the task in almost milliseconds.
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Author

Commented:
Hi Sudobh:
I'm running the macro using f8 I'd like to see each table.
Currently my screen remains on page 1. Where the first table is positioned.
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015
Commented:
Okay try this...
Sub FormatTableRow()
Dim doc As Document
Dim tbl As Table

Set doc = ActiveDocument
For Each tbl In doc.Tables
    tbl.Rows(1).Select
    With tbl.Rows(1).Range.Font
        .Bold = True
        .Size = 16
        .Name = "Arial"
    End With
Next tbl
MsgBox "Done!", vbInformation
End Sub

Open in new window

Author

Commented:
FLAWLESS!!!  Perfect!!!!
Thank you.
Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
You're welcome!
Thanks for the feedback.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial