Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
macro to detect merged table cells?
I'm wondering if there's a way to detect merged table cells.
As a test, I wrote the below code, wanting to examine each table in a document, then examine each cell. If I found a merged cell, I wanted to change the cell color to blue and display a message box stating "Merged cell." If the cell was not a merged cell, I wanted to change the cell color to red and display a message box stating "No merge detected." However, the code errors at this line: If oCell.Merge = True Then The error indicates that Merge is not an optional argument. I'm not sure if there's a way to detect merged cells in this manner. Here's all the code: Sub FindMergedCells() Dim oTable As Table Dim orow As Row Dim i As Integer Dim oCell As Cell For Each oTable In ActiveDocument.Tables For Each orow In oTable.Rows For Each oCell In orow.Cells If oCell.Merge = True Then ' ** code errors here ** oCell.Shading.BackgroundPatternColor = wdColorBlue MsgBox "Merged cell." Else oCell.Shading.BackgroundPatternColor = wdColorRed MsgBox "No merge detected." Next oCell Next orow Next oTable End Sub |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro runs from keyboard, but not from macro button-why? | Microsoft Word Help | |||
Merged cells make row disappear in table | Tables | |||
Table in a Form | Tables | |||
Select specific cells in table via macro | Microsoft Word Help | |||
Adding columns in table with merged cells | Tables |