Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Kimm
 
Posts: n/a
Default At my wit's end with macro

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
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Kimm
 
Posts: n/a
Default At my wit's end with macro

I posted this to the wrong board so I am reposting in the programming section.

"Kimm" wrote:

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

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
macro produces error message Kimmie B Microsoft Word Help 11 March 14th 06 11:25 PM
Macro Button Won't Stay on Toolbar caleb Microsoft Word Help 2 June 14th 05 11:59 PM
Possible bug when recording a Word Macro Raven95 Microsoft Word Help 4 April 30th 05 09:49 PM
Save As is not working due to macro security settings Craig Meritz Microsoft Word Help 1 December 16th 04 03:53 AM
2000 to 2002 macro and "Could not open macro storage" Art Farrell Mailmerge 1 December 6th 04 12:40 PM


All times are GMT +1. The time now is 12:46 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"