Macro in Word 2003 (To Reset All Tables Shading)

Posted on 2006-04-19
Last Modified: 2010-04-17
I have some .DOC documents created in Word 2003,
There are many tables inside
There is yellow shading in the table.

I am trying to create a macro to reset shading for all tables at once.
There is some error in the CODE.

Plz modify the code.   500 Pts.

Sub TableShadingOff()

Dim oTable As Table
Dim varTexture As Variant
Dim varForegroundPatternColor As Variant
Dim varBackgroundPatternColor As Variant
' Assign Texture, B/F color to Table

varTexture = wdTextureNone
varForegroundPatternColor = wdColorAutomatic
varBackgroundPatternColor = wdColorAutomatic
' Make these defaults
With Options
.DefaultBorderLineStyle = varTexture
.DefaultBorderLineWidth = varForegroundPatternColor
.DefaultBorderColor = varBackgroundPatternColor
End With

' variables ready now-------------------------------------------

' Reset B/F color on all tables in document
For Each oTable In ActiveDocument.Tables
    With oTable
            With .Shading
                .LineStyle = varTexture
                .LineWidth = varForegroundPatternColor
                .Color = varBackgroundPatternColor
            End With
            .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
            .Borders(wdBorderRight).LineStyle = wdLineStyleNone
            .Borders(wdBorderTop).LineStyle = wdLineStyleNone
            .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
            .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
            .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
            .Borders.Shadow = False
    End With
    With Options
        .DefaultBorderLineStyle = wdLineStyleSingle
        .DefaultBorderLineWidth = wdLineWidth050pt
        .DefaultBorderColor = wdColorAutomatic
    End With
Next oTable

End Sub
Question by:sunilcomputer

    Expert Comment

    One suggestion

    You can change shading manually while recording a macro

    and can use that code

    sorry if u have already tried this
    LVL 7

    Author Comment

    I have solved it myself.

    LVL 65

    Accepted Solution

    Hey sunilcomputer, sorry I didnt respond to your earlier question

    Since I last posted, Ive been away, now Im back, Im going through my emails

    Are you still having problems with it? It seems others are
    I found this article which claims to have some info that may help you with links. Not sure if it will help but have a look anyway


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Title # Comments Views Activity
    sum28 challenge 31 82
    Enhanced For loop vs ForEach Loop 4 42
    VB 6.0 printer how to align 6 36
    nestparen challenge 4 34
    A short article about a problem I had getting the GPS LocationListener working.
    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now