• Find/Replace Shading? (2003)

    Author
    Topic
    #457002

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #1144379

      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

      • #1144383

        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?

        • #1144389

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

          • #1144394

            Here’s a sample of what I am working with.

            • #1144400

              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

            • #1144401

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

              THANK YOU!

    Viewing 0 reply threads
    Reply To: Find/Replace Shading? (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: