Word 2003 Macro (To set Table Shading Default)

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
LVL 7
sunilcomputerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KennyTMCommented:
Have you tried

            With .Shading
                .Texture = varTexture
                .ForegroundPatternColor = varForegroundPatternColor
                .BackgroundPatternColor = varBackgroundPatternColor
            End With

?
KennyTMCommented:
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 = wdLineStyleSingle
    .DefaultBorderLineWidth = wdLineWidth050pt
    .DefaultBorderColor = wdColorAutomatic
End With

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

' Reset B/F color on all tables in document
'
For Each oTable In ActiveDocument.Tables
   
    MsgBox oTable.Shading.Texture
   
    With oTable

            With .Shading
            .Texture = varTexture
            .ForegroundPatternColor = varForegroundPatternColor
            .BackgroundPatternColor = 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
Next oTable

End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.