![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]() Quote:
http://www.dummies.com/how-to/conten...word-2013.html http://www.dummies.com/how-to/conten...word-2010.html http://www.addbalance.com/usersguide/styles.htm Quote:
Code:
.Range.Font.Name = "Times New Roman" .Range.Font.Size = 10 .Range.ParagraphFormat.Alignment = wdAlignParagraphCenter Code:
.Range.Style = "Tbl" • Name = "Times New Roman" • Size = 10 • Bold = True • Alignment = wdAlignParagraphLeft you could replace: Code:
.Range.Style = "Strong" .Range.ParagraphFormat.Alignment = wdAlignParagraphLeft Code:
.Range.Style = "TblHdr"
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Okay, thanks Paul...works great. I was so focused on that Table Grid and Table Normal I missing this part about creating the new styles. Appreciate your assistance as always.
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |
![]() |
Marrick13 | Word VBA | 14 | 12-11-2013 09:12 PM |