S
stevewy
I have written a short macro (pasted in below) that works on the
current table that the cursor is in, but I want it to run on all the
tables (except the very first one) in the document in one go. I tried
using For Each but the macro keeps bringing up errors, presumably
because there needs to be some alterations of the
"Selection.Tables(1)" bit where it occurs. Or is there something else
wrong? Any help would be appreciated. Thanks.
Sub Staff_Survey_Processing()
Selection.Find.ClearFormatting
With Selection.Find
.text = "Housing and Community Development"
.Replacement.text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.SelectRow
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Cut
With Selection.Tables(1)
.Cell(4, 1).Select
Selection.SelectRow
Selection.MoveDown Unit:=wdLine, Count:=26, Extend:=wdExtend
Selection.Rows.Delete
Selection.PasteAppendTable
.TopPadding = InchesToPoints(0.02)
.BottomPadding = InchesToPoints(0.02)
.LeftPadding = InchesToPoints(0.08)
.RightPadding = InchesToPoints(0.08)
.Spacing = 0
.Cell(4, 1).Select
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.Collapse
End With
End Sub
Steve Wylie
Canterbury
Kent
UK
current table that the cursor is in, but I want it to run on all the
tables (except the very first one) in the document in one go. I tried
using For Each but the macro keeps bringing up errors, presumably
because there needs to be some alterations of the
"Selection.Tables(1)" bit where it occurs. Or is there something else
wrong? Any help would be appreciated. Thanks.
Sub Staff_Survey_Processing()
Selection.Find.ClearFormatting
With Selection.Find
.text = "Housing and Community Development"
.Replacement.text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.SelectRow
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Cut
With Selection.Tables(1)
.Cell(4, 1).Select
Selection.SelectRow
Selection.MoveDown Unit:=wdLine, Count:=26, Extend:=wdExtend
Selection.Rows.Delete
Selection.PasteAppendTable
.TopPadding = InchesToPoints(0.02)
.BottomPadding = InchesToPoints(0.02)
.LeftPadding = InchesToPoints(0.08)
.RightPadding = InchesToPoints(0.08)
.Spacing = 0
.Cell(4, 1).Select
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.Collapse
End With
End Sub
Steve Wylie
Canterbury
Kent
UK