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?
 
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
0
 
KennyTMCommented:
Have you tried

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

?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.