WD97: ParagraphFormat.Shading Shades Cells Black Instead of Selected Color (241508)



The information in this article applies to:

  • Microsoft Word 97 for Windows

This article was previously published under Q241508

SYMPTOMS

When you run a Visual Basic for Applications macro to shade text contained in a table cell, the text may be shaded with black instead of the color shading that you specified in your macro code.

For example, if you select the four center cells of a Word table with four rows and four columns, and then run the following Visual Basic for Applications macro code, the selected cells will be shaded black instead of red:
With Selection.ParagraphFormat.Shading
   .ForegroundPatternColorIndex = wdRed
   .Texture = wdTextureSolid
End With
				

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

Use the Paragraphs.Format.Shading function instead of ParagraphFormat.Shading, as in the following example:
Sub Test()
    Dim pr As Paragraph
    For Each pr In Selection.Paragraphs
        With pr.Format.Shading
            .ForegroundPatternColorIndex = wdRed
            .Texture = wdTextureSolid
        End With
    Next
End Sub
				

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Modification Type:MajorLast Reviewed:6/17/2005
Keywords:kbbug kbmacroexample kbnofix KB241508