Aneef
Aneef

Reputation: 3729

PowerPoint 2007 Tables: Identify Merged Cells

How do I identify merged cells in PowerPoint 2007? Is there anyway we could find a particular cell is merged.

In 2003 we tried to access the Fill.Visible property of a cell and when it throws an error we can identify the cell as a merged cell. How do we achive this in 2007?

Upvotes: 5

Views: 1230

Answers (4)

konahn
konahn

Reputation: 371

Recently, I dug into the mystery of merged cells in the PowerPoint table. I ended up figuring out my own methods to deal with merged cells.

Please refer to the following link: https://stackoverflow.com/a/74563860/6354194

There are a few useful functions for merged cells:

  1. test if the cell is merged
  2. test if the cell is the first(Top-Left) cell of the merged area
  3. get the index no. of the cells in the merged area, top to bottom, left to right
  4. get the width and height of merged area
  5. test if the given cells are within a merged area

Upvotes: 0

Oliver Bock
Oliver Bock

Reputation: 5095

Cells that are merged together will have the same cell.Shape.Name. Unfortunately while this works on PowerPoint 2003, you get NotImplementedException when asking for the name of these Shapes on PowerPoint 2007. I don't know about later versions.

Upvotes: 0

ipetrovych
ipetrovych

Reputation: 81

I think much better would be to compare c1.Left == c2.Left && c1.Top == c2.Top. This would mean that the 2 cells are merged. To traverse all the cells just once I just remove "duplicates" using LINQ's Distinct and custom Comparer.

Upvotes: 1

Todd Main
Todd Main

Reputation: 29153

It's tough. However, the best way I've found is to check the width of the cell. This code isn't the best as it catches every cell, but it could be a starting point for you:

Dim r As Row
Dim co As Column
Dim c As Cell
For Each co In tbl.Columns
    For Each c In co.Cells
        If c.Shape.Width <> co.Width Then
            Debug.Print "Is merged cell"
        End If
    Next
Next

In a 2x2 table where cells 2.1 and 2.2 are merged (i.e. the second row is now one cell), this will print "Is merged cell" twice because internally the table still maintains cells 2.1 and 2.2. But it's a starting point as stated...

Upvotes: 2

Related Questions