vba - Powerpoint VBA - 均匀分布列

标签 vba powerpoint

我使用的 PowerPoint 2000 没有 2003 及更新版本所具有的均匀分布列功能。有谁知道使用什么VBA代码来均匀分布选定的表列?

(我知道如何通过查找表格宽度,将其除以列数,并将每列的宽度调整为除后的宽度来对整个表格执行此操作。但是,我在仅将其应用于选择时遇到问题. 例如,7 列表格中的右 5 列。)

最佳答案

这将为您解决问题。只需确保运行此命令时选择了列即可。

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

关于vba - Powerpoint VBA - 均匀分布列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1922421/

相关文章:

c# - 如何在 C# 中为 PPTX 文件生成缩略图?

vba - Excel 宏中列中的第一个可用单元格

excel - 使用 Excel 计算分子量

vba - 连接 DAO Access 时出现错误 429

vba - 从文件夹中的PowerPoint幻灯片中的文本框中删除字符串-错误ActiveX组件无法创建对象

powerpoint - 演示文稿的语法高亮主题

vba - 在VBA中更改文本框的颜色(阴影关闭/颜色渐变)

vba - Excel VBA - 更改单元格时运行宏

arrays - 将 Active Directory 中的值填充到 VBA 中的数组

vba - PowerPoint VBA : which command (or a set of commands) would create ppt frames out of my . jpg 图片?