How to make selected columns the same width in a PowerPoint table?

Is there a way to programmatically make only some columns in a PowerPoint table of the same width? It should be their width, taking into account the width, divided by the number of columns, but I cannot figure out how to do this.

+4
source share
1 answer

I already answered somewhere, could not find this link. Here's the code you need, just make sure you have the selected columns that you want to distribute evenly

Sub DistributeSelectedColumnsEvenly() Dim sel As Selection Set sel = ActiveWindow.Selection Dim fColumn As Integer fColumn = 0 Dim lColumn As Integer Dim columnsWidth As Integer With sel If .Type = ppSelectionShapes Then If .ShapeRange.Type = msoTable Then Dim tbl As Table Set tbl = .ShapeRange.Table Dim tblColumnCount As Integer tblColumnCount = tbl.Columns.Count For colNum = 1 To tblColumnCount If tbl.Cell(1, colNum).Selected Then columnsWidth = columnsWidth + tbl.Cell(1, colNum).Parent.Columns(colNum).Width If fColumn = 0 Then fColumn = colNum End If lColumn = colNum End If Next Dim columnCount As Integer columnCount = (lColumn - fColumn) + 1 Dim columnWidth As Integer columnWidth = columnsWidth / columnCount For columnIndex = fColumn To lColumn tbl.Columns(columnIndex).Width = columnWidth Next End If End If End With End Sub 
+3
source

Source: https://habr.com/ru/post/1300109/


All Articles