我正在使用PowerPoint 2000,它没有2003和更新版本具有的分布列均匀功能。有谁知道将使用什么VBA代码来均匀分配选定的表格列?
(我知道如何通过查找表格宽度,将其除以列数,并将每列的宽度调整为分割宽度来为WHOLE表格执行此操作。但是,我在将其仅应用于选择时遇到问题例如,在7列表中右5列。)
答案 0 :(得分:2)
这将为您解决问题。只需确保在运行时选择了列。
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
答案 1 :(得分:1)
获取您尝试分发的列的宽度总和,然后除以列数。