K
Kimm
Hello,
Hopefully someone can rescue me before I jump off the bridge. I am
attempting to create a macro that finds all occurences of a specific style
("Business Rule") in a table and highlights them. Once they are highlighted,
I would like the macro to then shade the cells. Here is what I have but when
I run it, absolutely nothing is changed so I don't even know if the macro
runs.
Is there anyone who can save me before it's too late?
Dim oCell As Cell
Dim sTextToFind As String
If Selection.Information(wdWithInTable) = False Then
MsgBox "Cursor is not currently in a table"
Else
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Business Rule")
Selection.Find.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
Do While Selection.Find.Execute = True
Selection.EndKey
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorGray25
End With
Loop
End With
End If
End Sub
Hopefully someone can rescue me before I jump off the bridge. I am
attempting to create a macro that finds all occurences of a specific style
("Business Rule") in a table and highlights them. Once they are highlighted,
I would like the macro to then shade the cells. Here is what I have but when
I run it, absolutely nothing is changed so I don't even know if the macro
runs.
Is there anyone who can save me before it's too late?
Dim oCell As Cell
Dim sTextToFind As String
If Selection.Information(wdWithInTable) = False Then
MsgBox "Cursor is not currently in a table"
Else
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Business Rule")
Selection.Find.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
Do While Selection.Find.Execute = True
Selection.EndKey
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorGray25
End With
Loop
End With
End If
End Sub