Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-01-2016, 02:28 PM
jeffreybrown jeffreybrown is offline Formatting all tables in doc with specific word in title Windows Vista Formatting all tables in doc with specific word in title Office 2007
Expert
Formatting all tables in doc with specific word in title
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default Formatting all tables in doc with specific word in title

I've been able to cobble this macro together to format all tables in the doc which the first row of the table begins with either "Table" of "Figure".

Two questions:

1) How can I modify a style so it will produce TNR and 10 along with the alignment. I've tried to modify "Table Grid", but everything I read shows says this can't be modified as it is based on "Table Normal" and that you can't modify? The doc is all TNR 12 except for the body of a Table which is 10. Table header also remains 12 which I set to "Strong" in the macro below.

2) Also, are there any areas in this macro that could be modified to further use any built in styles within Word?

Code:
Sub FormatFirstTableRow()
    Dim Tbl As Table
    Dim i As Long
    Dim iRow As Row
    Application.ScreenUpdating = False
    For Each Tbl In ActiveDocument.Tables
        With Tbl
            .Range.Font.Name = "Times New Roman"
            .Range.Font.Size = 10
            .Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
            .Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
            .Rows(1).Select
            If InStr(1, Selection.text, "Table") = 1 Or InStr(1, Selection.text, "Figure") = 1 Then
                With .Rows(1)
                    .Range.Style = "Strong"
                    .Borders.Enable = False
                    .Borders(wdBorderBottom).LineStyle = Options.DefaultBorderLineStyle
                    .Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
                    .Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
                End With
                .AutoFitBehavior (wdAutoFitContent)
                .Rows.HeightRule = wdRowHeightExactly
                .Rows.Height = InchesToPoints(0.2)
            End If
        End With
    Next
    ActiveDocument.Fields.Update
    Application.ScreenUpdating = True
End Sub

Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting all tables in doc with specific word in title VBA Word - Format ALL Tables - Apply Specific Formatting to Sets of Columns – Font, Border & Width jc491 Word VBA 10 11-04-2015 04:02 PM
Export calendar events from multiple calendars with specific title rasmus Outlook 0 02-06-2015 01:58 AM
Formatting contents after Tab of continuous lines or formatting specific area of word pawii Word 1 05-12-2014 05:24 AM
formatting specific area of word like we do in office star application pawii Word 0 05-06-2014 08:41 AM
Formatting all tables in doc with specific word in title True Title Case for First Row of All Tables Marrick13 Word VBA 14 12-11-2013 09:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft