How do I tell if I am in a PPT cell that is merged (and it's not the first one)

J

Ji Zhou

Hello Dave,

There is no way to tell. After the 3 cells are merged, they are considered
as the same cell. So if you get the COM object for any of them, it returns
the totally same properties which belongs to the merged cell.

Actually, based on my test, in PowerPnt programming, if we want to get a
cell, we have to use Table.Cell(index, index). Since we already know the
index of the cell before we get its instance, why we need to know whether
the cell is or is not the first cell of a a series?

If you have any questions on this, please update and I will try my best to
follow up.

Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
D

David Thielen

Hi;

Yes, this is a problem for us because our AddIn walks the objects in
each slide. So when we walk the cells, we get the same cell 3 times in
this case.

This is a major problem because we can have a tag in that merged cell,
and we do not want to process it 3 times.

thanks - dave


Hello Dave,

There is no way to tell. After the 3 cells are merged, they are considered
as the same cell. So if you get the COM object for any of them, it returns
the totally same properties which belongs to the merged cell.

Actually, based on my test, in PowerPnt programming, if we want to get a
cell, we have to use Table.Cell(index, index). Since we already know the
index of the cell before we get its instance, why we need to know whether
the cell is or is not the first cell of a a series?

If you have any questions on this, please update and I will try my best to
follow up.

Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Ji Zhou

Hello Dave,

OK. If we do not want to process it 3 times, we can do the following logics,

1. First, we got the table's Left property by table.Cell(1,1).Shape.Left.
2. In our iteration of the Cells of that table, if the the columnindex is
not 1 and the cell's Left equals to the table's Left, that means the cell is
a merged cell but not the first one.

The following C# codes work fine in my side,
----------------------------
PowerPoint.Application app =
Marshal.GetActiveObject("PowerPoint.Application") as PowerPoint.Application;

PowerPoint.Presentation pres = app.ActivePresentation;
PowerPoint.Table table = pres.Slides[1].Shapes[1].Table ;
int rowsCount = table.Rows.Count;
int columnsCount = table.Columns.Count;
float tableLeft = table.Cell(1,1).Shape.Left ;
for (int i = 1; i <= rowsCount; i++)
{
for (int j = 1; j <= columnsCount; j++)
{
if (j != 1 && table.Cell(i, j).Shape.Left == tableLeft)
{
Console.WriteLine("Cell " + i.ToString() + " " +
j.ToString() + " is merged cell, and not the first one");
}
}
}
----------------------------

Hope this helps! Let me know if you have further questions on this. Have a
nice day!


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
D

David Thielen

Really good idea - will try.

thanks - dave


Hello Dave,

OK. If we do not want to process it 3 times, we can do the following logics,

1. First, we got the table's Left property by table.Cell(1,1).Shape.Left.
2. In our iteration of the Cells of that table, if the the columnindex is
not 1 and the cell's Left equals to the table's Left, that means the cell is
a merged cell but not the first one.

The following C# codes work fine in my side,
----------------------------
PowerPoint.Application app =
Marshal.GetActiveObject("PowerPoint.Application") as PowerPoint.Application;

PowerPoint.Presentation pres = app.ActivePresentation;
PowerPoint.Table table = pres.Slides[1].Shapes[1].Table ;
int rowsCount = table.Rows.Count;
int columnsCount = table.Columns.Count;
float tableLeft = table.Cell(1,1).Shape.Left ;
for (int i = 1; i <= rowsCount; i++)
{
for (int j = 1; j <= columnsCount; j++)
{
if (j != 1 && table.Cell(i, j).Shape.Left == tableLeft)
{
Console.WriteLine("Cell " + i.ToString() + " " +
j.ToString() + " is merged cell, and not the first one");
}
}
}
----------------------------

Hope this helps! Let me know if you have further questions on this. Have a
nice day!


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support




David Thielen said:
Hi;

Yes, this is a problem for us because our AddIn walks the objects in
each slide. So when we walk the cells, we get the same cell 3 times in
this case.

This is a major problem because we can have a tag in that merged cell,
and we do not want to process it 3 times.

thanks - dave





david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

It worked great - thanks - dave

Hello Dave,

OK. If we do not want to process it 3 times, we can do the following logics,

1. First, we got the table's Left property by table.Cell(1,1).Shape.Left.
2. In our iteration of the Cells of that table, if the the columnindex is
not 1 and the cell's Left equals to the table's Left, that means the cell is
a merged cell but not the first one.

The following C# codes work fine in my side,
----------------------------
PowerPoint.Application app =
Marshal.GetActiveObject("PowerPoint.Application") as PowerPoint.Application;

PowerPoint.Presentation pres = app.ActivePresentation;
PowerPoint.Table table = pres.Slides[1].Shapes[1].Table ;
int rowsCount = table.Rows.Count;
int columnsCount = table.Columns.Count;
float tableLeft = table.Cell(1,1).Shape.Left ;
for (int i = 1; i <= rowsCount; i++)
{
for (int j = 1; j <= columnsCount; j++)
{
if (j != 1 && table.Cell(i, j).Shape.Left == tableLeft)
{
Console.WriteLine("Cell " + i.ToString() + " " +
j.ToString() + " is merged cell, and not the first one");
}
}
}
----------------------------

Hope this helps! Let me know if you have further questions on this. Have a
nice day!


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support




David Thielen said:
Hi;

Yes, this is a problem for us because our AddIn walks the objects in
each slide. So when we walk the cells, we get the same cell 3 times in
this case.

This is a major problem because we can have a tag in that merged cell,
and we do not want to process it 3 times.

thanks - dave





david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top