WD97: Cannot Set More Than One Property on Merged Cell Using Range Object

ID: Q239573


The information in this article applies to:
  • Microsoft Word 97 for Windows


SYMPTOMS

When you set more than one property of a merged cell within a Word table through a Range object of a Cell object, none of the changes is applied to the merged cell.


WORKAROUND

To work around this problem, refresh the Cell object and Range object references between the setting of a single property on a cell within a table with merged cells. As illustrated in the following example code:


Sub BuildTable()
  ' Create the table with merged cell
  ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:=4
  With ActiveDocument.Tables(1)
        .Cell(Row:=1, Column:=3).Merge _
        MergeTo:=.Cell(Row:=2, Column:=3)
       .Cell(Row:=2, Column:=1).Merge _
        MergeTo:=.Cell(Row:=4, Column:=2)
  End With
  shadecell
End Sub

Sub shadecell()
  Dim i As Integer
  Dim mycellrange As Range
  Dim startrange As Range
    For i = 1 To ActiveDocument.Tables(1).Range.Cells.Count
        Set mycellrange = ActiveDocument.Tables(1).Range.Cells(i).Range
        Set startrange = ActiveDocument.Range(Start:=mycellrange.Start, _
          End:=mycellrange.Start)
        With startrange.Cells.Shading
          .BackgroundPatternColorIndex = wdBrightGreen
        End With
        'MsgBox "cell = " & i
    Next i
    For i = 1 To ActiveDocument.Tables(1).Range.Cells.Count
        Set mycellrange = ActiveDocument.Tables(1).Range.Cells(i).Range
        Set startrange = ActiveDocument.Range(Start:=mycellrange.Start, _
          End:=mycellrange.Start)
        With startrange.Cells.Shading
          .Texture = wdTexture25Percent
        End With
    Next i
    For i = 1 To ActiveDocument.Tables(1).Range.Cells.Count
        Set mycellrange = ActiveDocument.Tables(1).Range.Cells(i).Range
        Set startrange = ActiveDocument.Range(Start:=mycellrange.Start, _
          End:=mycellrange.Start)
        With startrange.Cells.Shading
          .ForegroundPatternColorIndex = wdAuto
        End With
    Next i
End Sub 


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


Additional query words:

Keywords :
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: October 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.