M
Michael Koerner
I have the following macro, that someone here provided for me a couple of
years ago. I would like to have the macro when it inserts he header row
character put a dash before and after (-A-) and also make the row height
0.24 high. I have no idea how to do this, and any help would be gratefully
appreciated.
Sub InsertHeaderRow()
Dim Init As String
Dim newrow As Row
Dim dtable As Table
Dim i As Long
If Not Selection.Information(wdWithInTable) Then
MsgBox "You must position the cursor in a table.", _
vbExclamation, "Error"
Exit Sub
End If
Set dtable = Selection.Tables(1)
With dtable
i = 1
Do
If UCase(.Rows(i).Cells(1).Range.Characters(1)) _
<> Init Then
Init = UCase(.Rows(i).Cells(1).Range.Characters(1))
Set newrow = .Rows.Add(.Rows(i))
With newrow
.Cells.Merge
.Cells(1).Range.ParagraphFormat _
.Alignment = wdAlignParagraphCenter
.Range.Text = Init
.Range.Font.Bold = True
.Range.Shading _
.BackgroundPatternColor = wdColorGray10
End With
End If
i = i + 1
Loop While i <= .Rows.Count
End With
End Sub
years ago. I would like to have the macro when it inserts he header row
character put a dash before and after (-A-) and also make the row height
0.24 high. I have no idea how to do this, and any help would be gratefully
appreciated.
Sub InsertHeaderRow()
Dim Init As String
Dim newrow As Row
Dim dtable As Table
Dim i As Long
If Not Selection.Information(wdWithInTable) Then
MsgBox "You must position the cursor in a table.", _
vbExclamation, "Error"
Exit Sub
End If
Set dtable = Selection.Tables(1)
With dtable
i = 1
Do
If UCase(.Rows(i).Cells(1).Range.Characters(1)) _
<> Init Then
Init = UCase(.Rows(i).Cells(1).Range.Characters(1))
Set newrow = .Rows.Add(.Rows(i))
With newrow
.Cells.Merge
.Cells(1).Range.ParagraphFormat _
.Alignment = wdAlignParagraphCenter
.Range.Text = Init
.Range.Font.Bold = True
.Range.Shading _
.BackgroundPatternColor = wdColorGray10
End With
End If
i = i + 1
Loop While i <= .Rows.Count
End With
End Sub