0
votes

I am using Excel VBA to copy tables from a workbook into Powerpoint, and I'm using:

Shape.Table.Rows.Cell.Shape.TextFrame.TextRange.Font.Size = 20

to format the font size of the cells. However, on one computer, this function highlights the content of the cells to change the font size (similar to how you would highlight text to change font size by hand), and on a different computer, this line of code changes the font sizes without needing to highlight the actual text. Does anyone know why this is working differently (could it be a basic settings difference)?

I do not want the code to highlight the text because when the text is highlighted and the macro tries to paste another table on the slide, it pastes the table in the highlighted cell, instead of as a new separate table.

1

1 Answers

0
votes

Assuming that the shape in fact contains a table, try looping through each cell within the table using the Cell method of the Table object...

Dim lRow As Long
Dim lCol As Long

With oShape.Table
    For lRow = 1 To .Rows.Count
        For lCol = 1 To .Columns.Count
            .Cell(lRow, lCol).Shape.TextFrame.TextRange.Font.Size = 20
        Next lCol
    Next lRow
End With