Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Tokyo, Japan
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Replace Cell Color with Another (Word 2002)

    I have a folder with a couple of hundred Word document files based on a template with a formatted table. I would like to change the orange shade colored cell to a brownish shade. The attached file is a trimmed down version of the template has the exact color codes that I want replaced. Is there a easier way to automate this task? Thanks in advance.
    Attached Files Attached Files

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

    Re: Replace Cell Color with Another (Word 2002)

    See <post:=703,225>post 703,225</post:>, replace the ReplaceInDoc procedure with

    Sub ReplaceInDoc(doc As Document)
    Dim tbl As Table
    Dim cel As Cell
    For Each tbl In doc.Tables
    For Each cel In tbl.Range.Cells
    With cel.Shading
    If .BackgroundPatternColor = RGB(255, 153, 0) Then
    .BackgroundPatternColor = RGB(199, 169, 116)
    End If
    End With
    Next cel
    Next tbl
    End Sub

    then run the ReplaceInFolder macro.

  3. #3
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Tokyo, Japan
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Replace Cell Color with Another (Word 2002)

    This is excellent Hans. Thank you very much.

  4. #4
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Tokyo, Japan
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Replace Cell Color with Another (Word 2002)

    I have another situation this time deleting the last two tables on the same group of files. I will attach a sample file. I've marked the last two table as Table 6 and Table 7. Could you once again assist me on this. Thanks very much!!!
    Attached Files Attached Files

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Replace Cell Color with Another (Word 2002)

    To delete the last table in each document you can add the VBA code
    <code>doc.Tables(doc.Tables.Count).Delete</code>
    before the line
    <code>For Each tbl In doc.Tables</code>

    Include this single line of code twice in a row to delete the last two tables in each document.

    Please test this on a copy of the folder full of documents, to make sure it really is what you want.

    StuartR

  6. #6
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Tokyo, Japan
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Replace Cell Color with Another (Word 2002)

    Thanks Stuart. I worked beautifully.

Posting Permissions

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