Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Find/Replace Shading? (2003)

    I have some documents that have 25% gray shading. When we scan the document, it is coming out too dark, SO... I need to replace all 25%Gray with 12.5% Gray.
    I can't seem to create a macro that searches for the coloring. Any suggestions?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find/Replace Shading? (2003)

    Try this:

    Sub LightenUp()
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
    .Text = ""
    .ClearFormatting
    .Font.Shading.BackgroundPatternColor = wdColorGray25
    .Forward = True
    .Wrap = wdFindStop
    Do While .Execute
    Selection.Font.Shading.BackgroundPatternColor = wdColorGray125
    Selection.Collapse Direction:=wdCollapseEnd
    Loop
    End With
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Find/Replace Shading? (2003)

    Reading through the code, it makes sense to me, but it doesn't seem to work.
    My cursor does go to the beginning of the document, but then it just sits there.
    I tried stepping through the code, but it just sits there. Any other ideas?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find/Replace Shading? (2003)

    It worked in my test document.
    Could you attach a small sample document in which the code doesn't work?

  5. #5
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Find/Replace Shading? (2003)

    Here's a sample of what I am working with.
    Attached Files Attached Files

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find/Replace Shading? (2003)

    I had only taken font shading into account. The version below also takes paragraph shading and cell shading into account:

    Sub LightenUp()
    ' Font shading
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
    .Text = ""
    .ClearFormatting
    .Font.Shading.BackgroundPatternColor = wdColorGray25
    .Forward = True
    .Wrap = wdFindStop
    Do While .Execute
    Selection.Font.Shading.BackgroundPatternColor = wdColorGray125
    Selection.Collapse Direction:=wdCollapseEnd
    Loop
    End With
    ' Paragraph shading
    Dim par As Paragraph
    For Each par In ActiveDocument.Paragraphs
    If par.Shading.BackgroundPatternColor = wdColorGray25 Then
    par.Shading.BackgroundPatternColor = wdColorGray125
    End If
    Next par
    ' Cell shading
    Dim tbl As Table
    Dim cel As Cell
    For Each tbl In ActiveDocument.Tables
    tbl.Select
    For Each cel In Selection.Cells
    If cel.Shading.BackgroundPatternColor = wdColorGray25 Then
    cel.Shading.BackgroundPatternColor = wdColorGray125
    End If
    Next cel
    Next tbl
    End Sub

  7. #7
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Find/Replace Shading? (2003)

    Hans, that was awesome! I blinked and 22 pages were converted!


    THANK YOU!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •