?
Solved

Word 2003 Macro (To set Table Shading Default)

Posted on 2006-04-19
3
Medium Priority
?
223 Views
Last Modified: 2010-04-07
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
0
Comment
Question by:sunilcomputer
  • 2
2 Comments
 
LVL 8

Expert Comment

by:KennyTM
ID: 16486281
Have you tried

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

?
0
 
LVL 8

Accepted Solution

by:
KennyTM earned 1500 total points
ID: 16486344
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

840 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